Skip to content

Commit 8eb42c3

Browse files
committed
refactor: 统一命名规范从gemini-code改为gemini-cli
更新代码库中所有相关命名,将"gemini-code"统一改为"gemini-cli",包括: - 配置文件路径 - 端口文件命名规范 - 认证系统描述 - 环境变量命名 - 容器镜像路径 同时改进IDE端口发现机制,增加兼容性处理
1 parent 3f21178 commit 8eb42c3

7 files changed

Lines changed: 354 additions & 1061 deletions

File tree

src/pages/Checkpointing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ async setupShadowGitRepository() {
433433
434434
// 创建专用 Git 配置,避免继承用户全局配置
435435
const gitConfigContent =
436-
'[user]\\n name = Gemini CLI\\n email = gemini-code@google.com\\n[commit]\\n gpgsign = false\\n';
436+
'[user]\\n name = Gemini CLI\\n email = gemini-cli@google.com\\n[commit]\\n gpgsign = false\\n';
437437
await fs.writeFile(gitConfigPath, gitConfigContent);
438438
439439
// 初始化 Git 仓库

src/pages/EnterpriseDeployment.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function Introduction({ isExpanded, onToggle }: { isExpanded: boolean; onToggle:
6565

6666
const relatedPages: RelatedPage[] = [
6767
{ id: 'auth', label: '认证流程', description: 'OAuth 与 Token 管理机制' },
68-
{ id: 'google-authentication', label: 'Google OAuth 认证', description: 'Google OAuth 设备流程详解' },
68+
{ id: 'google-authentication', label: 'Google OAuth 认证', description: 'Loopback 回调与 NO_BROWSER/PKCE' },
6969
{ id: 'config', label: '配置系统', description: '环境变量与配置文件管理' },
7070
{ id: 'sandbox', label: '沙箱系统', description: '容器化部署与安全隔离' },
7171
{ id: 'non-interactive', label: '非交互模式', description: 'CI/CD 场景下的 CLI 使用' },
@@ -388,10 +388,10 @@ export async function checkForUpdates(): Promise<UpdateObject | null> {
388388
<HighlightBox title="手动更新方法" variant="blue">
389389
<CodeBlock
390390
code={`# npm 全局安装
391-
npm update -g @gemini-code/gemini-code
391+
npm update -g @google/gemini-cli
392392
393393
# 或安装指定版本
394-
npm install -g @gemini-code/gemini-code@1.2.3
394+
npm install -g @google/gemini-cli@1.2.3
395395
396396
# Portable 版:替换 app/ 目录即可
397397
cp -r new-version/app/* portable-win-x64/app/`}

src/pages/GitServiceDeep.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ export class GitService {
167167
168168
// 专用 gitconfig,避免继承用户配置
169169
const gitConfigContent = \`[user]
170-
name = Gemini Cli
171-
email = gemini-code@google.com
170+
name = Gemini CLI
171+
email = gemini-cli@google.com
172172
[commit]
173173
gpgsign = false
174174
\`;

src/pages/IDEDiffProtocol.tsx

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ export function IDEDiffProtocol() {
88
const connectionFlowChart = `flowchart TD
99
start([CLI 启动<br/>/ide enable])
1010
detect[检测 IDE<br/>进程树]
11-
read_port[读取端口文件<br/>/tmp/gemini-code-ide-server-ppid.json]
11+
try_compat[兼容读取<br/>/tmp/gemini-ide-server-{idePid}.json]
12+
compat_ok{读取成功?}
13+
scan_dir[扫描目录<br/>/tmp/gemini/ide/]
14+
pick_file[筛选文件<br/>gemini-ide-server-{idePid}-*.json]
15+
read_port[读取端口配置<br/>{ port, workspacePath, authToken }]
1216
validate{验证 Workspace<br/>路径匹配?}
1317
mcp_connect[MCP Client<br/>建立 HTTP SSE]
1418
discover[发现可用工具<br/>openDiff/closeDiff]
1519
connected([IDEConnectionStatus<br/>= Connected])
1620
failed([连接失败<br/>提示安装插件])
1721
1822
start --> detect
19-
detect --> read_port
23+
detect --> try_compat
24+
try_compat --> compat_ok
25+
compat_ok -->|Yes| read_port
26+
compat_ok -->|No| scan_dir
27+
scan_dir --> pick_file
28+
pick_file --> read_port
2029
read_port --> validate
2130
validate -->|No| failed
2231
validate -->|Yes| mcp_connect
@@ -26,7 +35,8 @@ export function IDEDiffProtocol() {
2635
style start fill:#22d3ee,color:#000
2736
style connected fill:#22c55e,color:#000
2837
style failed fill:#ef4444,color:#fff
29-
style validate fill:#f59e0b,color:#000`;
38+
style validate fill:#f59e0b,color:#000
39+
style compat_ok fill:#f59e0b,color:#000`;
3040

3141
// Diff View 完整交互流程
3242
const diffFlowChart = `flowchart TD
@@ -197,7 +207,7 @@ async showDiff(filePath: string, newContent: string) {
197207
198208
const createMcpServer = (diffManager: DiffManager) => {
199209
const server = new McpServer({
200-
name: 'gemini-code-companion-mcp-server',
210+
name: 'gemini-cli-companion-mcp-server',
201211
version: '1.0.0',
202212
}, { capabilities: { logging: {} } });
203213
@@ -292,43 +302,38 @@ this.client.setNotificationHandler(
292302
},
293303
);`;
294304

295-
const portFileCode = `// 端口发现机制
296-
// 来源: packages/vscode-ide-companion/src/ide-server.ts:51-95
297-
298-
// 1. Extension 启动时写入端口文件
299-
async function writePortAndWorkspace({
300-
port, portFile, ppidPortFile, authToken, ...
301-
}) {
302-
const content = JSON.stringify({
303-
port, // 随机分配的端口号
304-
workspacePath, // VS Code 打开的工作区路径
305-
ppid: process.ppid, // 父进程 ID (用于匹配 CLI)
306-
authToken, // Bearer Token
307-
});
305+
const portFileCode = `// 端口发现机制(上游 gemini-cli)
306+
// Extension 侧:gemini-cli/packages/vscode-ide-companion/src/ide-server.ts
307+
//
308+
// 写入目录:/tmp/gemini/ide/
309+
// 文件名: gemini-ide-server-{idePid}-{port}.json
310+
// 其中 idePid = process.ppid(VS Code 进程 ID),port 为随机监听端口
308311
309-
// 写入两个文件:
310-
// - /tmp/gemini-code-ide-server-{port}.json
311-
// - /tmp/gemini-code-ide-server-{ppid}.json
312-
await Promise.all([
313-
fs.writeFile(portFile, content).then(() => fs.chmod(portFile, 0o600)),
314-
fs.writeFile(ppidPortFile, content).then(() => fs.chmod(ppidPortFile, 0o600)),
315-
]);
316-
}
312+
const portDir = path.join(os.tmpdir(), 'gemini', 'ide');
313+
await fs.mkdir(portDir, { recursive: true });
317314
318-
// 2. CLI 侧读取端口文件
319-
// 来源: packages/core/src/ide/ide-client.ts:571-667
315+
const portFile = path.join(
316+
portDir,
317+
\`gemini-ide-server-\${process.ppid}-\${port}.json\`,
318+
);
320319
321-
private async getConnectionConfigFromFile() {
322-
// 通过进程树找到 IDE 的 PID
323-
const portFile = path.join(
324-
os.tmpdir(),
325-
\`gemini-code-ide-server-\${this.ideProcessInfo.pid}.json\`
326-
);
320+
await fs.writeFile(
321+
portFile,
322+
JSON.stringify({
323+
port,
324+
workspacePath,
325+
ppid: process.ppid,
326+
authToken,
327+
}),
328+
{ mode: 0o600 },
329+
);
327330
328-
const portFileContents = await fs.promises.readFile(portFile, 'utf8');
329-
return JSON.parse(portFileContents);
330-
// { port: 54321, workspacePath: '/path/to/project', authToken: 'xxx' }
331-
}`;
331+
// CLI 侧:gemini-cli/packages/core/src/ide/ide-client.ts
332+
//
333+
// 1) 兼容旧版本:先尝试读取 /tmp/gemini-ide-server-{idePid}.json
334+
// 2) 新版本:扫描 /tmp/gemini/ide/ 下所有 gemini-ide-server-{idePid}-*.json
335+
// 3) workspacePath 必须匹配当前 cwd(防止连错窗口)
336+
// 4) 多窗口时,可用 GEMINI_CLI_IDE_SERVER_PORT 指定端口进行选择`;
332337

333338
const contextSyncCode = `// IDE 上下文同步
334339
// 来源: packages/vscode-ide-companion/src/ide-server.ts:97-118
@@ -808,7 +813,8 @@ this.client.setNotificationHandler(
808813
<HighlightBox title="端口文件格式" icon="📄" variant="blue">
809814
<div className="text-sm">
810815
<p className="mb-2">
811-
端口文件位于 <code>/tmp/gemini-code-ide-server-&lt;ppid&gt;.json</code>
816+
端口文件位于 <code>/tmp/gemini/ide/gemini-ide-server-&lt;idePid&gt;-&lt;port&gt;.json</code>(兼容旧版:
817+
<code className="ml-1">/tmp/gemini-ide-server-&lt;idePid&gt;.json</code>):
812818
</p>
813819
<CodeBlock
814820
code={`{

src/pages/IDEIntegration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ class DiffContentProvider implements TextDocumentContentProvider {
515515
language="typescript"
516516
code={`// MCP Server 注册工具
517517
const mcpServer = new McpServer({
518-
name: 'gemini-code-companion-mcp-server',
518+
name: 'gemini-cli-companion-mcp-server',
519519
version: '1.0.0',
520520
});
521521

src/pages/StartupChain.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function QuickSummary({ isExpanded, onToggle }: { isExpanded: boolean; onToggle:
8383
<div className="flex items-center gap-2 flex-wrap text-xs">
8484
<span className="px-2 py-1 bg-red-500/20 text-red-400 rounded border border-red-500/30">CLI 参数</span>
8585
<span className="text-[var(--text-muted)]">&gt;</span>
86-
<span className="px-2 py-1 bg-yellow-500/20 text-yellow-400 rounded border border-yellow-500/30">/etc/gemini-code/</span>
86+
<span className="px-2 py-1 bg-yellow-500/20 text-yellow-400 rounded border border-yellow-500/30">/etc/gemini-cli/</span>
8787
<span className="text-[var(--text-muted)]">&gt;</span>
8888
<span className="px-2 py-1 bg-green-500/20 text-green-400 rounded border border-green-500/30">.gemini/</span>
8989
<span className="text-[var(--text-muted)]">&gt;</span>
@@ -200,7 +200,7 @@ export function StartupChain() {
200200
participant App as initializeApp
201201
202202
Main->>LS: 加载配置文件
203-
Note right of LS: 1. systemDefaults.json<br/>2. ~/.gemini/settings.json<br/>3. .gemini/settings.json<br/>4. /etc/gemini-code/settings.json
203+
Note right of LS: 合并优先级(后者覆盖前者):<br/>1. system-defaults.json<br/>2. ~/.gemini/settings.json<br/>3. .gemini/settings.json<br/>4. /etc/gemini-cli/settings.json (macOS/Windows 路径不同)
204204
LS-->>Main: LoadedSettings
205205
206206
Main->>LA: 解析命令行参数
@@ -248,7 +248,7 @@ export function StartupChain() {
248248
<ul className="list-disc list-inside space-y-2 ml-4">
249249
<li>加载和合并多层级配置(系统默认、用户、项目、系统覆盖)</li>
250250
<li>检测和启动沙箱环境(macOS Seatbelt、Docker、Podman)</li>
251-
<li>初始化认证系统(Google OAuth、OpenAI API、Google Login</li>
251+
<li>初始化认证系统(Google OAuth、Gemini API Key、Vertex AI/ADC</li>
252252
<li>加载扩展和 MCP 服务器配置</li>
253253
<li>根据运行环境选择正确的模式(交互式、非交互式、Zed 集成)</li>
254254
</ul>
@@ -270,7 +270,7 @@ export function StartupChain() {
270270
<ul className="text-sm space-y-1">
271271
<li>• Node.js &gt;= 20 运行时</li>
272272
<li>• 配置文件(可选):~/.gemini/settings.json</li>
273-
<li>• 环境变量(可选):OPENAI_API_KEY, GEMINI_SANDBOX 等</li>
273+
<li>• 环境变量(可选):GEMINI_API_KEY / GEMINI_MODEL / GEMINI_SANDBOX / NO_BROWSER</li>
274274
<li>• Git 可用(如启用 checkpointing)</li>
275275
</ul>
276276
</HighlightBox>
@@ -424,7 +424,7 @@ return customDeepMerge(
424424
systemDefaults, // 1. 基础默认值
425425
user, // 2. 用户设置覆盖 (~/.gemini/settings.json)
426426
safeWorkspace, // 3. 工作区覆盖 (.gemini/settings.json, 需信任)
427-
system, // 4. 系统覆盖 (/etc/gemini-code/settings.json, 最高优先)
427+
system, // 4. 系统覆盖 (/etc/gemini-cli/settings.json, 最高优先)
428428
) as Settings;`}
429429
/>
430430
</Layer>
@@ -458,7 +458,7 @@ return customDeepMerge(
458458
<div className="text-sm space-y-2">
459459
<p className="text-gray-300">容器化隔离</p>
460460
<p className="text-xs text-gray-500">
461-
镜像: ghcr.io/google/generative-ai-cli:VERSION
461+
镜像: us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:VERSION
462462
</p>
463463
<p className="text-xs text-gray-500">
464464
检测: docker/podman 命令可用
@@ -633,18 +633,18 @@ main().catch((error) => {
633633
<td className="border border-gray-700 p-3 text-gray-500">auto-detect</td>
634634
</tr>
635635
<tr className="bg-gray-800/30">
636-
<td className="border border-gray-700 p-3 font-mono text-cyan-400">OPENAI_API_KEY</td>
637-
<td className="border border-gray-700 p-3">OpenAI 兼容 API 密钥</td>
636+
<td className="border border-gray-700 p-3 font-mono text-cyan-400">GEMINI_API_KEY</td>
637+
<td className="border border-gray-700 p-3">Gemini API Key(AuthType=gemini-api-key)</td>
638638
<td className="border border-gray-700 p-3 text-gray-500">-</td>
639639
</tr>
640640
<tr>
641-
<td className="border border-gray-700 p-3 font-mono text-cyan-400">OPENAI_BASE_URL</td>
642-
<td className="border border-gray-700 p-3">OpenAI 兼容 API 基础 URL</td>
641+
<td className="border border-gray-700 p-3 font-mono text-cyan-400">GEMINI_MODEL</td>
642+
<td className="border border-gray-700 p-3">Gemini 模型名称</td>
643643
<td className="border border-gray-700 p-3 text-gray-500">-</td>
644644
</tr>
645645
<tr className="bg-gray-800/30">
646-
<td className="border border-gray-700 p-3 font-mono text-cyan-400">GEMINI_MODEL</td>
647-
<td className="border border-gray-700 p-3">Gemini 模型名称</td>
646+
<td className="border border-gray-700 p-3 font-mono text-cyan-400">GOOGLE_CLOUD_PROJECT</td>
647+
<td className="border border-gray-700 p-3">Vertex AI 项目(AuthType=vertex-ai)</td>
648648
<td className="border border-gray-700 p-3 text-gray-500">-</td>
649649
</tr>
650650
<tr>
@@ -661,18 +661,23 @@ main().catch((error) => {
661661
</table>
662662
</div>
663663

664+
<div className="mt-3 bg-amber-500/10 border border-amber-500/30 rounded-lg p-3 text-sm text-gray-300">
665+
<strong className="text-amber-400">Fork-only:</strong>
666+
某些衍生实现会加入 <code>OPENAI_API_KEY</code> / <code>OPENAI_BASE_URL</code> 等 OpenAI 兼容环境变量;上游 <code>gemini-cli</code> 不包含该认证分支。
667+
</div>
668+
664669
<h4 className="text-lg font-semibold text-cyan-400 mt-6">配置文件路径</h4>
665670
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
666671
<div className="bg-gray-900 rounded-lg p-4 border border-gray-700">
667672
<h5 className="font-semibold text-green-400 mb-2">系统级配置</h5>
668673
<ul className="text-sm space-y-1 text-gray-300">
669674
<li>
670-
<code className="text-yellow-300">/etc/gemini-code/settings.json</code>
675+
<code className="text-yellow-300">/etc/gemini-cli/settings.json</code>
671676
<span className="text-gray-500 ml-2">(最高优先级)</span>
672677
</li>
673678
<li>
674-
<code className="text-yellow-300">systemDefaults.json</code>
675-
<span className="text-gray-500 ml-2">(内置默认)</span>
679+
<code className="text-yellow-300">system-defaults.json</code>
680+
<span className="text-gray-500 ml-2">(同目录, 最低优先级)</span>
676681
</li>
677682
</ul>
678683
</div>
@@ -704,7 +709,7 @@ main().catch((error) => {
704709
},
705710
"security": {
706711
"auth": {
707-
"selectedType": "google-oauth" // 认证类型: google-oauth | openai-api
712+
"selectedType": "oauth-personal" // 认证类型: oauth-personal | gemini-api-key | vertex-ai | compute-default-credentials | cloud-shell
708713
}
709714
},
710715
"tools": {
@@ -715,8 +720,7 @@ main().catch((error) => {
715720
]
716721
},
717722
"ide": {
718-
"enabled": false, // IDE 集成模式
719-
"ideServerUri": "http://localhost:3000"
723+
"enabled": false // IDE 集成模式
720724
},
721725
"mcpServers": { // MCP 服务器配置
722726
"sequential-thinking": {

0 commit comments

Comments
 (0)