@zqagent/core 0.2.20 → 0.3.6

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 (238) hide show
  1. package/README.md +1 -1
  2. package/README.oss.en.md +3 -3
  3. package/README.oss.md +8 -3
  4. package/README.oss.zh-TW.md +3 -3
  5. package/dist/McpClient-CEQBUPuC.d.cts +145 -0
  6. package/dist/McpClient-CEQBUPuC.d.ts +145 -0
  7. package/dist/{ToolRegistry-C3pTFiaJ.d.cts → ToolRegistry-Cy0fQxrb.d.ts} +2 -111
  8. package/dist/{ToolRegistry-C3pTFiaJ.d.ts → ToolRegistry-DouDvn9E.d.cts} +2 -111
  9. package/dist/{explore-RtZtb-V6.d.ts → TurnEngine-BPKhWuSI.d.cts} +108 -73
  10. package/dist/{explore-BgRhj6SP.d.cts → TurnEngine-DtGEuVLT.d.ts} +108 -73
  11. package/dist/conflictGuard-BBOOIxxK.d.cts +42 -0
  12. package/dist/conflictGuard-BBOOIxxK.d.ts +42 -0
  13. package/dist/index.cjs +5418 -1096
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +577 -195
  16. package/dist/index.d.ts +577 -195
  17. package/dist/index.js +5299 -1011
  18. package/dist/index.js.map +1 -1
  19. package/dist/internal/crypto/secrets.cjs +25 -0
  20. package/dist/internal/crypto/secrets.cjs.map +1 -0
  21. package/dist/internal/crypto/secrets.d.cts +2 -0
  22. package/dist/internal/crypto/secrets.d.ts +2 -0
  23. package/dist/internal/crypto/secrets.js +3 -0
  24. package/dist/internal/crypto/secrets.js.map +1 -0
  25. package/dist/internal/engine/FileLogHook.cjs +179 -0
  26. package/dist/internal/engine/FileLogHook.cjs.map +1 -0
  27. package/dist/internal/engine/FileLogHook.d.cts +67 -0
  28. package/dist/internal/engine/FileLogHook.d.ts +67 -0
  29. package/dist/internal/engine/FileLogHook.js +144 -0
  30. package/dist/internal/engine/FileLogHook.js.map +1 -0
  31. package/dist/internal/engine/approvalView.cjs +25 -0
  32. package/dist/internal/engine/approvalView.cjs.map +1 -0
  33. package/dist/internal/engine/approvalView.d.cts +1 -0
  34. package/dist/internal/engine/approvalView.d.ts +1 -0
  35. package/dist/internal/engine/approvalView.js +3 -0
  36. package/dist/internal/engine/approvalView.js.map +1 -0
  37. package/dist/internal/engine/limits.cjs +59 -0
  38. package/dist/internal/engine/limits.cjs.map +1 -0
  39. package/dist/internal/engine/limits.d.cts +32 -0
  40. package/dist/internal/engine/limits.d.ts +32 -0
  41. package/dist/internal/engine/limits.js +31 -0
  42. package/dist/internal/engine/limits.js.map +1 -0
  43. package/dist/internal/engine/sessionNaming.cjs +47 -0
  44. package/dist/internal/engine/sessionNaming.cjs.map +1 -0
  45. package/dist/internal/engine/sessionNaming.d.cts +25 -0
  46. package/dist/internal/engine/sessionNaming.d.ts +25 -0
  47. package/dist/internal/engine/sessionNaming.js +20 -0
  48. package/dist/internal/engine/sessionNaming.js.map +1 -0
  49. package/dist/internal/llmConfig.cjs +561 -0
  50. package/dist/internal/llmConfig.cjs.map +1 -0
  51. package/dist/internal/llmConfig.d.cts +75 -0
  52. package/dist/internal/llmConfig.d.ts +75 -0
  53. package/dist/internal/llmConfig.js +535 -0
  54. package/dist/internal/llmConfig.js.map +1 -0
  55. package/dist/internal/mcp/builtin/index.cjs +685 -0
  56. package/dist/internal/mcp/builtin/index.cjs.map +1 -0
  57. package/dist/internal/mcp/builtin/index.d.cts +21 -0
  58. package/dist/internal/mcp/builtin/index.d.ts +21 -0
  59. package/dist/internal/mcp/builtin/index.js +652 -0
  60. package/dist/internal/mcp/builtin/index.js.map +1 -0
  61. package/dist/internal/mcp/config.cjs +278 -0
  62. package/dist/internal/mcp/config.cjs.map +1 -0
  63. package/dist/internal/mcp/config.d.cts +61 -0
  64. package/dist/internal/mcp/config.d.ts +61 -0
  65. package/dist/internal/mcp/config.js +235 -0
  66. package/dist/internal/mcp/config.js.map +1 -0
  67. package/dist/internal/mcp/presets.cjs +184 -0
  68. package/dist/internal/mcp/presets.cjs.map +1 -0
  69. package/dist/internal/mcp/presets.d.cts +39 -0
  70. package/dist/internal/mcp/presets.d.ts +39 -0
  71. package/dist/internal/mcp/presets.js +158 -0
  72. package/dist/internal/mcp/presets.js.map +1 -0
  73. package/dist/internal/node-name.cjs +45 -0
  74. package/dist/internal/node-name.cjs.map +1 -0
  75. package/dist/internal/node-name.d.cts +3 -0
  76. package/dist/internal/node-name.d.ts +3 -0
  77. package/dist/internal/node-name.js +10 -0
  78. package/dist/internal/node-name.js.map +1 -0
  79. package/dist/internal/paths.cjs +63 -0
  80. package/dist/internal/paths.cjs.map +1 -0
  81. package/dist/internal/paths.d.cts +17 -0
  82. package/dist/internal/paths.d.ts +17 -0
  83. package/dist/internal/paths.js +25 -0
  84. package/dist/internal/paths.js.map +1 -0
  85. package/dist/internal/providers/diagnostics.cjs +288 -0
  86. package/dist/internal/providers/diagnostics.cjs.map +1 -0
  87. package/dist/internal/providers/diagnostics.d.cts +103 -0
  88. package/dist/internal/providers/diagnostics.d.ts +103 -0
  89. package/dist/internal/providers/diagnostics.js +250 -0
  90. package/dist/internal/providers/diagnostics.js.map +1 -0
  91. package/dist/internal/providers/models.cjs +699 -0
  92. package/dist/internal/providers/models.cjs.map +1 -0
  93. package/dist/internal/providers/models.d.cts +136 -0
  94. package/dist/internal/providers/models.d.ts +136 -0
  95. package/dist/internal/providers/models.js +654 -0
  96. package/dist/internal/providers/models.js.map +1 -0
  97. package/dist/internal/terminal.cjs +161 -0
  98. package/dist/internal/terminal.cjs.map +1 -0
  99. package/dist/internal/terminal.d.cts +58 -0
  100. package/dist/internal/terminal.d.ts +58 -0
  101. package/dist/internal/terminal.js +128 -0
  102. package/dist/internal/terminal.js.map +1 -0
  103. package/dist/internal/tools/execAsync.cjs +187 -0
  104. package/dist/internal/tools/execAsync.cjs.map +1 -0
  105. package/dist/internal/tools/execAsync.d.cts +30 -0
  106. package/dist/internal/tools/execAsync.d.ts +30 -0
  107. package/dist/internal/tools/execAsync.js +162 -0
  108. package/dist/internal/tools/execAsync.js.map +1 -0
  109. package/dist/internal/tools/git.cjs +935 -0
  110. package/dist/internal/tools/git.cjs.map +1 -0
  111. package/dist/internal/tools/git.d.cts +206 -0
  112. package/dist/internal/tools/git.d.ts +206 -0
  113. package/dist/internal/tools/git.js +883 -0
  114. package/dist/internal/tools/git.js.map +1 -0
  115. package/dist/internal/tools/pathSafety.cjs +99 -0
  116. package/dist/internal/tools/pathSafety.cjs.map +1 -0
  117. package/dist/internal/tools/pathSafety.d.cts +44 -0
  118. package/dist/internal/tools/pathSafety.d.ts +44 -0
  119. package/dist/internal/tools/pathSafety.js +61 -0
  120. package/dist/internal/tools/pathSafety.js.map +1 -0
  121. package/dist/internal/tools/plan.cjs +146 -0
  122. package/dist/internal/tools/plan.cjs.map +1 -0
  123. package/dist/internal/tools/plan.d.cts +48 -0
  124. package/dist/internal/tools/plan.d.ts +48 -0
  125. package/dist/internal/tools/plan.js +117 -0
  126. package/dist/internal/tools/plan.js.map +1 -0
  127. package/dist/internal/tools/ripgrep.cjs +118 -0
  128. package/dist/internal/tools/ripgrep.cjs.map +1 -0
  129. package/dist/internal/tools/ripgrep.d.cts +6 -0
  130. package/dist/internal/tools/ripgrep.d.ts +6 -0
  131. package/dist/internal/tools/ripgrep.js +89 -0
  132. package/dist/internal/tools/ripgrep.js.map +1 -0
  133. package/dist/internal/tools/sandbox.cjs +253 -0
  134. package/dist/internal/tools/sandbox.cjs.map +1 -0
  135. package/dist/internal/tools/sandbox.d.cts +67 -0
  136. package/dist/internal/tools/sandbox.d.ts +67 -0
  137. package/dist/internal/tools/sandbox.js +213 -0
  138. package/dist/internal/tools/sandbox.js.map +1 -0
  139. package/dist/internal/tools/shell.cjs +771 -0
  140. package/dist/internal/tools/shell.cjs.map +1 -0
  141. package/dist/internal/tools/shell.d.cts +47 -0
  142. package/dist/internal/tools/shell.d.ts +47 -0
  143. package/dist/internal/tools/shell.js +731 -0
  144. package/dist/internal/tools/shell.js.map +1 -0
  145. package/dist/internal/tools/shellRuntime.cjs +220 -0
  146. package/dist/internal/tools/shellRuntime.cjs.map +1 -0
  147. package/dist/internal/tools/shellRuntime.d.cts +67 -0
  148. package/dist/internal/tools/shellRuntime.d.ts +67 -0
  149. package/dist/internal/tools/shellRuntime.js +181 -0
  150. package/dist/internal/tools/shellRuntime.js.map +1 -0
  151. package/dist/internal/update/controller.cjs +1035 -0
  152. package/dist/internal/update/controller.cjs.map +1 -0
  153. package/dist/internal/update/controller.d.cts +150 -0
  154. package/dist/internal/update/controller.d.ts +150 -0
  155. package/dist/internal/update/controller.js +991 -0
  156. package/dist/internal/update/controller.js.map +1 -0
  157. package/dist/internal/update/platform.cjs +234 -0
  158. package/dist/internal/update/platform.cjs.map +1 -0
  159. package/dist/internal/update/platform.d.cts +77 -0
  160. package/dist/internal/update/platform.d.ts +77 -0
  161. package/dist/internal/update/platform.js +184 -0
  162. package/dist/internal/update/platform.js.map +1 -0
  163. package/dist/tools/ask.d.cts +3 -1
  164. package/dist/tools/ask.d.ts +3 -1
  165. package/dist/tools/diff.cjs +17 -6
  166. package/dist/tools/diff.cjs.map +1 -1
  167. package/dist/tools/diff.d.cts +5 -2
  168. package/dist/tools/diff.d.ts +5 -2
  169. package/dist/tools/diff.js +17 -6
  170. package/dist/tools/diff.js.map +1 -1
  171. package/dist/tools/directories.d.cts +3 -1
  172. package/dist/tools/directories.d.ts +3 -1
  173. package/dist/tools/explore.cjs +1778 -204
  174. package/dist/tools/explore.cjs.map +1 -1
  175. package/dist/tools/explore.d.cts +82 -2
  176. package/dist/tools/explore.d.ts +82 -2
  177. package/dist/tools/explore.js +1780 -204
  178. package/dist/tools/explore.js.map +1 -1
  179. package/dist/tools/files.cjs +56 -21
  180. package/dist/tools/files.cjs.map +1 -1
  181. package/dist/tools/files.d.cts +6 -3
  182. package/dist/tools/files.d.ts +6 -3
  183. package/dist/tools/files.js +56 -21
  184. package/dist/tools/files.js.map +1 -1
  185. package/dist/tools/git.cjs +34 -25
  186. package/dist/tools/git.cjs.map +1 -1
  187. package/dist/tools/git.d.cts +4 -204
  188. package/dist/tools/git.d.ts +4 -204
  189. package/dist/tools/git.js +34 -25
  190. package/dist/tools/git.js.map +1 -1
  191. package/dist/tools/media.cjs +280 -3
  192. package/dist/tools/media.cjs.map +1 -1
  193. package/dist/tools/media.d.cts +3 -1
  194. package/dist/tools/media.d.ts +3 -1
  195. package/dist/tools/media.js +278 -1
  196. package/dist/tools/media.js.map +1 -1
  197. package/dist/tools/plan.cjs +62 -0
  198. package/dist/tools/plan.cjs.map +1 -1
  199. package/dist/tools/plan.d.cts +4 -17
  200. package/dist/tools/plan.d.ts +4 -17
  201. package/dist/tools/plan.js +59 -0
  202. package/dist/tools/plan.js.map +1 -1
  203. package/dist/tools/search.cjs +3 -0
  204. package/dist/tools/search.cjs.map +1 -1
  205. package/dist/tools/search.d.cts +3 -1
  206. package/dist/tools/search.d.ts +3 -1
  207. package/dist/tools/search.js +3 -0
  208. package/dist/tools/search.js.map +1 -1
  209. package/dist/tools/shell.cjs +76 -11
  210. package/dist/tools/shell.cjs.map +1 -1
  211. package/dist/tools/shell.d.cts +5 -39
  212. package/dist/tools/shell.d.ts +5 -39
  213. package/dist/tools/shell.js +75 -11
  214. package/dist/tools/shell.js.map +1 -1
  215. package/dist/tools/todo.d.cts +3 -1
  216. package/dist/tools/todo.d.ts +3 -1
  217. package/dist/tools/web.cjs +279 -5
  218. package/dist/tools/web.cjs.map +1 -1
  219. package/dist/tools/web.d.cts +3 -1
  220. package/dist/tools/web.d.ts +3 -1
  221. package/dist/tools/web.js +275 -3
  222. package/dist/tools/web.js.map +1 -1
  223. package/dist/types-BYyXWWPW.d.cts +237 -0
  224. package/dist/types-BYyXWWPW.d.ts +237 -0
  225. package/package.json +26 -37
  226. package/bin/zqagent +0 -2
  227. package/dist/cli/index.cjs +0 -25218
  228. package/dist/cli/index.cjs.map +0 -1
  229. package/dist/cli/index.d.cts +0 -2
  230. package/dist/cli/index.d.ts +0 -2
  231. package/dist/cli/index.js +0 -25201
  232. package/dist/cli/index.js.map +0 -1
  233. package/dist/server/index.cjs +0 -20510
  234. package/dist/server/index.cjs.map +0 -1
  235. package/dist/server/index.d.cts +0 -2
  236. package/dist/server/index.d.ts +0 -2
  237. package/dist/server/index.js +0 -20493
  238. package/dist/server/index.js.map +0 -1
@@ -1,204 +1,4 @@
1
- import { T as ToolRegistry } from '../ToolRegistry-C3pTFiaJ.cjs';
2
-
3
- /** git_log — 提交历史 */
4
- declare function makeGitLog(workspace: string): (args: Record<string, unknown>) => Promise<{
5
- error: string;
6
- repo?: undefined;
7
- count?: undefined;
8
- commits?: undefined;
9
- } | {
10
- repo: string;
11
- count: number;
12
- commits: ({
13
- hash: string;
14
- author: string;
15
- date: string;
16
- subject: string;
17
- raw?: undefined;
18
- } | {
19
- raw: string;
20
- hash?: undefined;
21
- author?: undefined;
22
- date?: undefined;
23
- subject?: undefined;
24
- })[];
25
- error?: undefined;
26
- }>;
27
- /** git_status — 工作区状态 */
28
- declare function makeGitStatus(workspace: string): (args: Record<string, unknown>) => Promise<{
29
- error: string;
30
- repo?: undefined;
31
- clean?: undefined;
32
- entries?: undefined;
33
- count?: undefined;
34
- } | {
35
- repo: string;
36
- clean: boolean;
37
- entries: {
38
- status: string;
39
- file: string;
40
- index: string;
41
- worktree: string;
42
- }[];
43
- count: number;
44
- error?: undefined;
45
- }>;
46
- /** git_diff — 差异对比 */
47
- declare function makeGitDiff(workspace: string): (args: Record<string, unknown>) => Promise<{
48
- error: string;
49
- repo?: undefined;
50
- staged?: undefined;
51
- path?: undefined;
52
- diff?: undefined;
53
- truncated?: undefined;
54
- } | {
55
- repo: string;
56
- staged: boolean;
57
- path: string | null;
58
- diff: string;
59
- truncated: boolean;
60
- error?: undefined;
61
- }>;
62
- /** 注册 Git 工具 */
63
- declare function registerGitTools(registry: ToolRegistry, workspace: string): void;
64
- /** 写操作结果:ok=false 时 error 为可直接展示给用户的原因 */
65
- interface GitOpResult {
66
- ok: boolean;
67
- stdout: string;
68
- stderr: string;
69
- error?: string;
70
- }
71
- /** 分支名校验(拒绝空、选项注入与 git 非法字符);返回 null 表示可用 */
72
- declare function gitRefProblem(name: string): string | null;
73
- /** git_branches — 本地分支列表 + 当前分支(detached 时 current 为短 hash) */
74
- declare function makeGitBranches(workspace: string): (args: Record<string, unknown>) => Promise<{
75
- error: string;
76
- repo?: undefined;
77
- current?: undefined;
78
- detached?: undefined;
79
- branches?: undefined;
80
- } | {
81
- repo: string;
82
- current: string;
83
- detached: boolean;
84
- branches: {
85
- upstream?: string | undefined;
86
- name: string;
87
- current: boolean;
88
- }[];
89
- error?: undefined;
90
- }>;
91
- /** 提交标识(hash / ref 名)校验:拒绝空、选项注入与 git 非法字符;返回 null 表示可用 */
92
- declare function gitObjectProblem(name: string): string | null;
93
- /**
94
- * git_refs — 引用列表(控制台 Git 面板)
95
- *
96
- * 一次返回本地分支 / 远程分支 / 标签三组,供面板分组展示与切换。
97
- * 远程分支与标签只有在 `git fetch` 之后才是服务端的最新状态(见 makeGitFetch)。
98
- */
99
- declare function makeGitRefs(workspace: string): (args: Record<string, unknown>) => Promise<{
100
- error: string;
101
- repo?: undefined;
102
- current?: undefined;
103
- detached?: undefined;
104
- local?: undefined;
105
- remote?: undefined;
106
- tags?: undefined;
107
- } | {
108
- repo: string;
109
- current: string;
110
- detached: boolean;
111
- local: {
112
- name: string;
113
- current?: boolean;
114
- upstream?: string;
115
- }[];
116
- remote: {
117
- name: string;
118
- }[];
119
- tags: {
120
- name: string;
121
- target?: string;
122
- }[];
123
- error?: undefined;
124
- }>;
125
- /**
126
- * git_show — 单次提交详情(meta + 变更文件 + diff)
127
- *
128
- * path 省略时返回整个提交的 diff(截断 50000 字符);给出 path 时只返回该文件
129
- * 在此提交中的 diff(相对第一父提交,merge commit 也能给出可读结果)。
130
- */
131
- declare function makeGitShow(workspace: string): (args: Record<string, unknown>) => Promise<{
132
- error: string;
133
- repo?: undefined;
134
- commit?: undefined;
135
- files?: undefined;
136
- path?: undefined;
137
- diff?: undefined;
138
- truncated?: undefined;
139
- } | {
140
- repo: string;
141
- commit: {
142
- hash: string;
143
- short: string;
144
- author: string;
145
- authorEmail: string;
146
- date: string;
147
- subject: string;
148
- body: string;
149
- };
150
- files: {
151
- status: string;
152
- file: string;
153
- }[];
154
- path: string | null;
155
- diff: string;
156
- truncated: boolean;
157
- error?: undefined;
158
- }>;
159
- /** git_stage — 暂存文件(paths 为空 = 全部改动) */
160
- declare function makeGitStage(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
161
- /** git_unstage — 取消暂存(paths 为空 = 全部) */
162
- declare function makeGitUnstage(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
163
- /** git_commit — 提交已暂存内容 */
164
- declare function makeGitCommit(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
165
- /** git_checkout — 切换分支(create=true 时新建并切换) */
166
- declare function makeGitCheckout(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
167
- /** git_pull — 拉取当前分支的上游 */
168
- declare function makeGitPull(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
169
- /** git_push — 推送当前分支(无 upstream 且存在 origin 时按首次推送补 -u) */
170
- declare function makeGitPush(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
171
- /** git_fetch — 刷新服务端分支与标签(--all --prune --tags) */
172
- declare function makeGitFetch(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
173
- interface GitRepoInfo {
174
- /** 相对工作区的路径;根仓库为 "" */
175
- path: string;
176
- /** 目录名(根仓库为工作区目录名) */
177
- name: string;
178
- /** 当前分支;detached 时为短 hash */
179
- branch?: string;
180
- detached?: boolean;
181
- }
182
- /**
183
- * 扫描工作区及其子目录中的 git 仓库。
184
- *
185
- * 遇到仓库后仍继续向下扫描:子模块与「仓库里嵌套独立仓库」的工程都能被发现。
186
- * 根仓库排在第一位,其余按相对路径排序。
187
- */
188
- declare function scanGitRepos(workspace: string, depth?: number): {
189
- repos: GitRepoInfo[];
190
- truncated?: boolean;
191
- };
192
- /** git_repos — 列出工作区内的所有 git 仓库(控制台 Git 面板的仓库选择器) */
193
- declare function makeGitRepos(workspace: string): (args: Record<string, unknown>) => Promise<{
194
- root: string;
195
- repos: never[];
196
- error: string;
197
- } | {
198
- repos: GitRepoInfo[];
199
- truncated?: boolean;
200
- root: string;
201
- error?: undefined;
202
- }>;
203
-
204
- export { type GitOpResult, type GitRepoInfo, gitObjectProblem, gitRefProblem, makeGitBranches, makeGitCheckout, makeGitCommit, makeGitDiff, makeGitFetch, makeGitLog, makeGitPull, makeGitPush, makeGitRefs, makeGitRepos, makeGitShow, makeGitStage, makeGitStatus, makeGitUnstage, registerGitTools, scanGitRepos };
1
+ import '../ToolRegistry-DouDvn9E.cjs';
2
+ export { GitOpResult, GitRepoInfo, gitObjectProblem, gitRefProblem, makeGitBranches, makeGitCheckout, makeGitCommit, makeGitDiff, makeGitFetch, makeGitLog, makeGitPull, makeGitPush, makeGitRefs, makeGitRepos, makeGitShow, makeGitStage, makeGitStatus, makeGitUnstage, registerGitTools, scanGitRepos } from '../internal/tools/git.cjs';
3
+ import '../types-BYyXWWPW.cjs';
4
+ import '@zqagent/shared/model-capabilities';
@@ -1,204 +1,4 @@
1
- import { T as ToolRegistry } from '../ToolRegistry-C3pTFiaJ.js';
2
-
3
- /** git_log — 提交历史 */
4
- declare function makeGitLog(workspace: string): (args: Record<string, unknown>) => Promise<{
5
- error: string;
6
- repo?: undefined;
7
- count?: undefined;
8
- commits?: undefined;
9
- } | {
10
- repo: string;
11
- count: number;
12
- commits: ({
13
- hash: string;
14
- author: string;
15
- date: string;
16
- subject: string;
17
- raw?: undefined;
18
- } | {
19
- raw: string;
20
- hash?: undefined;
21
- author?: undefined;
22
- date?: undefined;
23
- subject?: undefined;
24
- })[];
25
- error?: undefined;
26
- }>;
27
- /** git_status — 工作区状态 */
28
- declare function makeGitStatus(workspace: string): (args: Record<string, unknown>) => Promise<{
29
- error: string;
30
- repo?: undefined;
31
- clean?: undefined;
32
- entries?: undefined;
33
- count?: undefined;
34
- } | {
35
- repo: string;
36
- clean: boolean;
37
- entries: {
38
- status: string;
39
- file: string;
40
- index: string;
41
- worktree: string;
42
- }[];
43
- count: number;
44
- error?: undefined;
45
- }>;
46
- /** git_diff — 差异对比 */
47
- declare function makeGitDiff(workspace: string): (args: Record<string, unknown>) => Promise<{
48
- error: string;
49
- repo?: undefined;
50
- staged?: undefined;
51
- path?: undefined;
52
- diff?: undefined;
53
- truncated?: undefined;
54
- } | {
55
- repo: string;
56
- staged: boolean;
57
- path: string | null;
58
- diff: string;
59
- truncated: boolean;
60
- error?: undefined;
61
- }>;
62
- /** 注册 Git 工具 */
63
- declare function registerGitTools(registry: ToolRegistry, workspace: string): void;
64
- /** 写操作结果:ok=false 时 error 为可直接展示给用户的原因 */
65
- interface GitOpResult {
66
- ok: boolean;
67
- stdout: string;
68
- stderr: string;
69
- error?: string;
70
- }
71
- /** 分支名校验(拒绝空、选项注入与 git 非法字符);返回 null 表示可用 */
72
- declare function gitRefProblem(name: string): string | null;
73
- /** git_branches — 本地分支列表 + 当前分支(detached 时 current 为短 hash) */
74
- declare function makeGitBranches(workspace: string): (args: Record<string, unknown>) => Promise<{
75
- error: string;
76
- repo?: undefined;
77
- current?: undefined;
78
- detached?: undefined;
79
- branches?: undefined;
80
- } | {
81
- repo: string;
82
- current: string;
83
- detached: boolean;
84
- branches: {
85
- upstream?: string | undefined;
86
- name: string;
87
- current: boolean;
88
- }[];
89
- error?: undefined;
90
- }>;
91
- /** 提交标识(hash / ref 名)校验:拒绝空、选项注入与 git 非法字符;返回 null 表示可用 */
92
- declare function gitObjectProblem(name: string): string | null;
93
- /**
94
- * git_refs — 引用列表(控制台 Git 面板)
95
- *
96
- * 一次返回本地分支 / 远程分支 / 标签三组,供面板分组展示与切换。
97
- * 远程分支与标签只有在 `git fetch` 之后才是服务端的最新状态(见 makeGitFetch)。
98
- */
99
- declare function makeGitRefs(workspace: string): (args: Record<string, unknown>) => Promise<{
100
- error: string;
101
- repo?: undefined;
102
- current?: undefined;
103
- detached?: undefined;
104
- local?: undefined;
105
- remote?: undefined;
106
- tags?: undefined;
107
- } | {
108
- repo: string;
109
- current: string;
110
- detached: boolean;
111
- local: {
112
- name: string;
113
- current?: boolean;
114
- upstream?: string;
115
- }[];
116
- remote: {
117
- name: string;
118
- }[];
119
- tags: {
120
- name: string;
121
- target?: string;
122
- }[];
123
- error?: undefined;
124
- }>;
125
- /**
126
- * git_show — 单次提交详情(meta + 变更文件 + diff)
127
- *
128
- * path 省略时返回整个提交的 diff(截断 50000 字符);给出 path 时只返回该文件
129
- * 在此提交中的 diff(相对第一父提交,merge commit 也能给出可读结果)。
130
- */
131
- declare function makeGitShow(workspace: string): (args: Record<string, unknown>) => Promise<{
132
- error: string;
133
- repo?: undefined;
134
- commit?: undefined;
135
- files?: undefined;
136
- path?: undefined;
137
- diff?: undefined;
138
- truncated?: undefined;
139
- } | {
140
- repo: string;
141
- commit: {
142
- hash: string;
143
- short: string;
144
- author: string;
145
- authorEmail: string;
146
- date: string;
147
- subject: string;
148
- body: string;
149
- };
150
- files: {
151
- status: string;
152
- file: string;
153
- }[];
154
- path: string | null;
155
- diff: string;
156
- truncated: boolean;
157
- error?: undefined;
158
- }>;
159
- /** git_stage — 暂存文件(paths 为空 = 全部改动) */
160
- declare function makeGitStage(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
161
- /** git_unstage — 取消暂存(paths 为空 = 全部) */
162
- declare function makeGitUnstage(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
163
- /** git_commit — 提交已暂存内容 */
164
- declare function makeGitCommit(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
165
- /** git_checkout — 切换分支(create=true 时新建并切换) */
166
- declare function makeGitCheckout(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
167
- /** git_pull — 拉取当前分支的上游 */
168
- declare function makeGitPull(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
169
- /** git_push — 推送当前分支(无 upstream 且存在 origin 时按首次推送补 -u) */
170
- declare function makeGitPush(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
171
- /** git_fetch — 刷新服务端分支与标签(--all --prune --tags) */
172
- declare function makeGitFetch(workspace: string): (args: Record<string, unknown>) => Promise<GitOpResult>;
173
- interface GitRepoInfo {
174
- /** 相对工作区的路径;根仓库为 "" */
175
- path: string;
176
- /** 目录名(根仓库为工作区目录名) */
177
- name: string;
178
- /** 当前分支;detached 时为短 hash */
179
- branch?: string;
180
- detached?: boolean;
181
- }
182
- /**
183
- * 扫描工作区及其子目录中的 git 仓库。
184
- *
185
- * 遇到仓库后仍继续向下扫描:子模块与「仓库里嵌套独立仓库」的工程都能被发现。
186
- * 根仓库排在第一位,其余按相对路径排序。
187
- */
188
- declare function scanGitRepos(workspace: string, depth?: number): {
189
- repos: GitRepoInfo[];
190
- truncated?: boolean;
191
- };
192
- /** git_repos — 列出工作区内的所有 git 仓库(控制台 Git 面板的仓库选择器) */
193
- declare function makeGitRepos(workspace: string): (args: Record<string, unknown>) => Promise<{
194
- root: string;
195
- repos: never[];
196
- error: string;
197
- } | {
198
- repos: GitRepoInfo[];
199
- truncated?: boolean;
200
- root: string;
201
- error?: undefined;
202
- }>;
203
-
204
- export { type GitOpResult, type GitRepoInfo, gitObjectProblem, gitRefProblem, makeGitBranches, makeGitCheckout, makeGitCommit, makeGitDiff, makeGitFetch, makeGitLog, makeGitPull, makeGitPush, makeGitRefs, makeGitRepos, makeGitShow, makeGitStage, makeGitStatus, makeGitUnstage, registerGitTools, scanGitRepos };
1
+ import '../ToolRegistry-Cy0fQxrb.js';
2
+ export { GitOpResult, GitRepoInfo, gitObjectProblem, gitRefProblem, makeGitBranches, makeGitCheckout, makeGitCommit, makeGitDiff, makeGitFetch, makeGitLog, makeGitPull, makeGitPush, makeGitRefs, makeGitRepos, makeGitShow, makeGitStage, makeGitStatus, makeGitUnstage, registerGitTools, scanGitRepos } from '../internal/tools/git.js';
3
+ import '../types-BYyXWWPW.js';
4
+ import '@zqagent/shared/model-capabilities';
package/dist/tools/git.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/tools/git.ts
2
2
  import * as fs from "fs";
3
- import * as path from "path";
3
+ import * as path2 from "path";
4
4
 
5
5
  // src/tools/execAsync.ts
6
6
  import { spawn } from "child_process";
@@ -65,12 +65,12 @@ function makeSink(maxBuffer) {
65
65
  };
66
66
  }
67
67
  function execAsync(file, argv, opts = {}) {
68
- return new Promise((resolve2) => {
68
+ return new Promise((resolve3) => {
69
69
  const maxBuffer = opts.maxBuffer ?? DEFAULT_MAX_BUFFER;
70
70
  const out = makeSink(maxBuffer);
71
71
  const err = makeSink(maxBuffer);
72
72
  if (opts.signal?.aborted) {
73
- resolve2({
73
+ resolve3({
74
74
  status: null,
75
75
  stdout: Buffer.alloc(0),
76
76
  stderr: Buffer.alloc(0),
@@ -91,7 +91,7 @@ function execAsync(file, argv, opts = {}) {
91
91
  windowsHide: true
92
92
  });
93
93
  } catch (e) {
94
- resolve2({
94
+ resolve3({
95
95
  status: null,
96
96
  stdout: Buffer.alloc(0),
97
97
  stderr: Buffer.alloc(0),
@@ -128,7 +128,7 @@ function execAsync(file, argv, opts = {}) {
128
128
  };
129
129
  if (aborted) result.aborted = true;
130
130
  if (spawnError) result.error = spawnError;
131
- resolve2(result);
131
+ resolve3(result);
132
132
  };
133
133
  const killAndSettle = () => {
134
134
  killTree(child.pid);
@@ -287,6 +287,9 @@ var ShellTaskManager = class {
287
287
  }
288
288
  };
289
289
 
290
+ // src/tools/sandbox.ts
291
+ import { spawnSync as spawnSync2 } from "child_process";
292
+
290
293
  // src/tools/shell.ts
291
294
  var MAX_BUFFER = 1024 * 1024 * 5;
292
295
  function decodeOutput(buf) {
@@ -305,6 +308,12 @@ function decodeOutput(buf) {
305
308
  }
306
309
  var shellTasks = new ShellTaskManager();
307
310
 
311
+ // src/tools/pathSafety.ts
312
+ import * as path from "path";
313
+ function isInsideRelative(rel) {
314
+ return !path.isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${path.sep}`);
315
+ }
316
+
308
317
  // src/tools/git.ts
309
318
  async function runGit(repoDir, args, timeout = 15e3) {
310
319
  const res = await execAsync("git", ["-c", "core.quotepath=false", ...args], {
@@ -322,9 +331,9 @@ async function runGit(repoDir, args, timeout = 15e3) {
322
331
  async function resolveRepoRoot(workspace, pathArg) {
323
332
  let dir = workspace;
324
333
  if (pathArg) {
325
- const abs = path.resolve(workspace, pathArg);
334
+ const abs = path2.resolve(workspace, pathArg);
326
335
  try {
327
- dir = fs.statSync(abs).isDirectory() ? abs : path.dirname(abs);
336
+ dir = fs.statSync(abs).isDirectory() ? abs : path2.dirname(abs);
328
337
  } catch {
329
338
  dir = abs;
330
339
  }
@@ -337,24 +346,24 @@ function repoDirArg(workspace, raw) {
337
346
  if (typeof raw !== "string") return void 0;
338
347
  const v = raw.trim();
339
348
  if (!v) return void 0;
340
- const base = path.resolve(workspace);
341
- const abs = path.resolve(base, v);
342
- const rel = path.relative(base, abs);
343
- if (rel.startsWith("..") || path.isAbsolute(rel)) return void 0;
349
+ const base = path2.resolve(workspace);
350
+ const abs = path2.resolve(base, v);
351
+ const rel = path2.relative(base, abs);
352
+ if (!isInsideRelative(rel)) return void 0;
344
353
  return abs;
345
354
  }
346
355
  function toPathspec(repoRoot, workspace, pathArg) {
347
356
  if (!pathArg) return null;
348
- const abs = path.resolve(workspace, pathArg);
349
- let rel = path.relative(repoRoot, abs);
357
+ const abs = path2.resolve(workspace, pathArg);
358
+ let rel = path2.relative(repoRoot, abs);
350
359
  if (rel === "") return ".";
351
- if (rel.startsWith("..") || path.isAbsolute(rel)) {
360
+ if (!isInsideRelative(rel)) {
352
361
  try {
353
362
  const realRepo = fs.realpathSync(repoRoot);
354
363
  const realAbs = fs.realpathSync(abs);
355
- const rel2 = path.relative(realRepo, realAbs);
364
+ const rel2 = path2.relative(realRepo, realAbs);
356
365
  if (rel2 === "") return ".";
357
- if (!rel2.startsWith("..") && !path.isAbsolute(rel2)) return rel2;
366
+ if (isInsideRelative(rel2)) return rel2;
358
367
  } catch {
359
368
  }
360
369
  return null;
@@ -780,16 +789,16 @@ var SCAN_SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".hg", ".s
780
789
  var SCAN_DEFAULT_DEPTH = 3;
781
790
  var SCAN_MAX_DIRS = 2e3;
782
791
  function readRepoHead(repoDir) {
783
- const dotGit = path.join(repoDir, ".git");
792
+ const dotGit = path2.join(repoDir, ".git");
784
793
  try {
785
794
  let headFile;
786
795
  if (fs.statSync(dotGit).isDirectory()) {
787
- headFile = path.join(dotGit, "HEAD");
796
+ headFile = path2.join(dotGit, "HEAD");
788
797
  } else {
789
798
  const raw = fs.readFileSync(dotGit, "utf-8");
790
799
  const m = /^gitdir:\s*(.+)$/m.exec(raw);
791
800
  if (!m) return {};
792
- headFile = path.join(path.resolve(repoDir, m[1].trim()), "HEAD");
801
+ headFile = path2.join(path2.resolve(repoDir, m[1].trim()), "HEAD");
793
802
  }
794
803
  const head = fs.readFileSync(headFile, "utf-8").trim();
795
804
  const prefix = "ref: refs/heads/";
@@ -800,7 +809,7 @@ function readRepoHead(repoDir) {
800
809
  return {};
801
810
  }
802
811
  function scanGitRepos(workspace, depth = SCAN_DEFAULT_DEPTH) {
803
- const root = path.resolve(workspace);
812
+ const root = path2.resolve(workspace);
804
813
  const maxDepth = Number.isFinite(depth) ? Math.min(Math.max(Math.floor(depth), 0), 6) : SCAN_DEFAULT_DEPTH;
805
814
  const repos = [];
806
815
  const stack = [{ dir: root, depth: 0 }];
@@ -813,11 +822,11 @@ function scanGitRepos(workspace, depth = SCAN_DEFAULT_DEPTH) {
813
822
  truncated = true;
814
823
  break;
815
824
  }
816
- const rel = path.relative(root, dir).split(path.sep).join("/");
817
- if (fs.existsSync(path.join(dir, ".git"))) {
825
+ const rel = path2.relative(root, dir).split(path2.sep).join("/");
826
+ if (fs.existsSync(path2.join(dir, ".git"))) {
818
827
  repos.push({
819
828
  path: rel,
820
- name: rel ? path.basename(dir) : path.basename(root),
829
+ name: rel ? path2.basename(dir) : path2.basename(root),
821
830
  ...readRepoHead(dir)
822
831
  });
823
832
  }
@@ -830,7 +839,7 @@ function scanGitRepos(workspace, depth = SCAN_DEFAULT_DEPTH) {
830
839
  }
831
840
  for (const e of entries) {
832
841
  if (!e.isDirectory() || SCAN_SKIP_DIRS.has(e.name)) continue;
833
- stack.push({ dir: path.join(dir, e.name), depth: d + 1 });
842
+ stack.push({ dir: path2.join(dir, e.name), depth: d + 1 });
834
843
  }
835
844
  }
836
845
  repos.sort(
@@ -840,7 +849,7 @@ function scanGitRepos(workspace, depth = SCAN_DEFAULT_DEPTH) {
840
849
  }
841
850
  function makeGitRepos(workspace) {
842
851
  return async function git_repos(args) {
843
- const root = path.resolve(workspace);
852
+ const root = path2.resolve(workspace);
844
853
  try {
845
854
  if (!fs.statSync(root).isDirectory()) return { root, repos: [], error: "\u5DE5\u4F5C\u533A\u4E0D\u662F\u76EE\u5F55" };
846
855
  } catch {