MCPcopy Create free account
hub / github.com/echoVic/blade-code / preCheckCommand

Method preCheckCommand

src/tools/builtin/git/git-add.ts:135–165  ·  view source on GitHub ↗

* 预检查命令

(
    command: string,
    workingDirectory: string,
    _params: Record<string, any>
  )

Source from the content-addressed store, hash-verified

133 * 预检查命令
134 */
135 protected async preCheckCommand(
136 command: string,
137 workingDirectory: string,
138 _params: Record<string, any>
139 ): Promise<CommandPreCheckResult> {
140 try {
141 // 检查是否在 Git 仓库中
142 await execAsync('git rev-parse --git-dir', { cwd: workingDirectory });
143
144 return { valid: true };
145 } catch (error: any) {
146 if (error.message.includes('not a git repository')) {
147 return {
148 valid: false,
149 message: '当前目录不是 Git 仓库',
150 suggestions: [
151 {
152 command: 'git init',
153 description: '初始化 Git 仓库',
154 riskLevel: RiskLevel.SAFE,
155 },
156 ],
157 };
158 }
159
160 return {
161 valid: false,
162 message: `Git 预检查失败: ${error.message}`,
163 };
164 }
165 }
166
167 /**
168 * 获取执行描述

Callers 1

executeFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected