Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
{
|
|
|
|
|
"extends": "../../tsconfig.json",
|
|
|
|
|
"compilerOptions": {
|
2025-04-18 14:37:02 -07:00
|
|
|
"outDir": "dist",
|
2025-05-06 15:48:26 +00:00
|
|
|
"jsx": "react-jsx",
|
2026-05-01 12:14:33 +08:00
|
|
|
"baseUrl": ".",
|
2025-08-25 16:06:47 -04:00
|
|
|
"lib": ["DOM", "DOM.Iterable", "ES2023"],
|
2026-05-01 12:14:33 +08:00
|
|
|
"types": ["node", "vitest/globals"],
|
|
|
|
|
"paths": {
|
|
|
|
|
"@qwen-code/qwen-code-core": ["../core/src/index.ts"],
|
refactor(acp-bridge): create skeleton + lift zero-coupling primitives (#4175 PR 22a) (#4295)
* refactor(acp-bridge): create skeleton + lift zero-coupling primitives (#4175 PR 22a)
First slice of #4175 Wave 5 PR 22 (`refactor(serve): extract acp bridge
primitives`). Lifts the three primitives from `packages/cli/src/serve/`
that have zero coupling to the rest of `serve/`, so PR 22a can land
ahead of PR 17 (#4282) and PR 14b (#4271) without merge-conflict risk
on `httpAcpBridge.ts`. Also seeds the `PermissionMediator` interface
contract that PR 24 will implement (4 strategies — first-responder /
designated / consensus / local-only — replacing the inline
first-responder voting in `BridgeClient.requestPermission`).
What moves
- `cli/src/serve/eventBus.ts` (578 LOC, no internal imports) →
`packages/acp-bridge/src/eventBus.ts`
- `cli/src/serve/inMemoryChannel.ts` (73 LOC, only depends on
`@agentclientprotocol/sdk`) → `packages/acp-bridge/src/inMemoryChannel.ts`
- `httpAcpBridge.ts:638-677` `AcpChannel` / `AcpChannelExitInfo` /
`ChannelFactory` types → `packages/acp-bridge/src/channel.ts`
- Both test files moved alongside their sources
What's new
- `packages/acp-bridge/` package (`@qwen-code/acp-bridge`, internal,
not published to npm yet)
- `packages/acp-bridge/src/permission.ts` — type-only
`PermissionMediator` / `PermissionPolicy` / `PermissionResolution`
/ `PermissionRequestRecord` / `PermissionVote` /
`PermissionVoteOutcome`. No implementation; PR 24 fills it in.
- `packages/cli/src/serve/eventBus.ts` and `inMemoryChannel.ts` are
now one-line re-export wrappers for backward compat.
- `httpAcpBridge.ts:638-677` is now a one-line `import type` +
`export type` re-export.
Backward compatibility
- All existing relative imports (`./eventBus.js`,
`./inMemoryChannel.js`, `../serve/eventBus.js`) keep resolving via
the wrappers — no churn for the 8 importer sites in
`cli/src/serve/` plus `cli/src/commands/serve.ts:14`.
- `httpAcpBridge.ts` continues to export `AcpChannel` /
`AcpChannelExitInfo` / `ChannelFactory` so any external consumer
is unaffected.
- Zero `/capabilities` payload changes, zero HTTP route changes,
zero SDK behavior changes, zero spawn-site behavior changes.
What's not in this slice (deferred to PR 22b after PR 17/14b land)
- `BridgeClient` + `createHttpAcpBridge` factory + `defaultSpawnChannelFactory`
(~3000 LOC, lines 1082-3770 + 4106-4307 of `httpAcpBridge.ts`).
- Channel and VSCode-IDE-companion own-spawn migrations.
Tests
- `npm test --workspace @qwen-code/acp-bridge` — 28/28 pass
(eventBus 20 + inMemoryChannel 8) at the new location.
- `cd packages/cli && npx vitest run src/serve/` — 567/567 pass
(no regressions).
- `cd packages/cli && npx tsc --noEmit` clean.
References
- #4175 Wave 5 PR 22 row
- #3803 chiga0's "Stage 1.5-prereq AcpChannel lift"
- `httpAcpBridge.ts:679-696` FIXME for the four `PermissionMediator`
strategies this slice declares
* fix(acp-bridge): minimize package-lock.json diff to acp-bridge entries only
The previous commit ran `npm install --ignore-scripts`, which npm 11
treated as license to renormalize peer-dependency markers across the
entire lockfile and resolve `@types/react@18.3.28`,
`@types/react-dom@18.3.7`, and `@types/prop-types@15.7.15` away from
their pinned versions. CI's `npm ci` then refused to install because
the manifests no longer matched the lockfile.
Restored package-lock.json to origin/main and surgically added only the
three entries the new package actually requires:
- `node_modules/@qwen-code/acp-bridge` workspace symlink
- `packages/acp-bridge` workspace manifest snapshot
- `@qwen-code/acp-bridge` listed under `packages/cli`'s dependencies
`npm ci --no-audit --ignore-scripts` now succeeds (1453 packages, no
warnings about stale lockfile entries). Re-verified `acp-bridge`
package tests (28/28 pass) and `tsc --build` clean.
* fix(acp-bridge): address PR 22a review feedback
Three review-driven fixes:
1. **wenshao**: removed `src/**/*.test.ts` from `tsconfig.json` exclude
so the moved `eventBus.test.ts` and `inMemoryChannel.test.ts`
regain typecheck coverage. Pre-fix, a future change to
`BridgeEvent` / `SubscribeOptions` shape would only fail at
runtime; post-fix `tsc --noEmit` catches the mismatch. Matches
`packages/core/tsconfig.json`'s pattern (no test exclude;
emitted test artefacts in dist/ are accepted convention).
2. **Copilot**: corrected the FIXME line citation in
`permission.ts` and `README.md` from `1144-1154` to the actual
range `1096-1106` (the four-strategy FIXME inside
`BridgeClient.requestPermission`). Verified via grep against
current `httpAcpBridge.ts`.
3. **Copilot review summary**: added a "Imports — root vs subpaths"
section to README.md explaining when to use the barrel root
(`@qwen-code/acp-bridge`) vs per-module subpaths
(`/eventBus`, `/inMemoryChannel`, `/channel`, `/permission`),
and added `@see` JSDoc pointers in `cli/src/serve/eventBus.ts`
and `inMemoryChannel.ts` wrappers to the implementation files
for the design-rationale comments that moved to acp-bridge.
Verification: 28/28 acp-bridge tests + 567/567 cli serve tests
pass; `tsc --noEmit` clean across both packages including the
moved test files.
Declined (replied on the PR):
- Move `@agentclientprotocol/sdk` to `peerDependencies` — sound
advice in general but not yet relevant; package is internal
(`files: ["dist"]`, no npm publish), so dedupe is automatic
through monorepo file: links. Will revisit during PR 28
(npm alpha publish).
2026-05-19 01:23:08 +08:00
|
|
|
"@qwen-code/qwen-code-core/*": ["../core/src/*"],
|
|
|
|
|
"@qwen-code/acp-bridge": ["../acp-bridge/src/index.ts"],
|
|
|
|
|
"@qwen-code/acp-bridge/*": ["../acp-bridge/src/*"]
|
2026-05-01 12:14:33 +08:00
|
|
|
}
|
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
|
|
|
},
|
2025-06-17 08:24:07 -07:00
|
|
|
"include": [
|
|
|
|
|
"index.ts",
|
|
|
|
|
"src/**/*.ts",
|
|
|
|
|
"src/**/*.tsx",
|
|
|
|
|
"src/**/*.json",
|
2026-01-14 15:30:27 +08:00
|
|
|
"./package.json",
|
|
|
|
|
"../core/src/utils/toml-to-markdown-converter.test.ts",
|
|
|
|
|
"../core/src/utils/toml-to-markdown-converter.ts"
|
2025-06-17 08:24:07 -07:00
|
|
|
],
|
2025-07-07 23:41:39 -07:00
|
|
|
"exclude": [
|
|
|
|
|
"node_modules",
|
|
|
|
|
"dist",
|
2025-08-14 10:35:34 -07:00
|
|
|
// TODO(5691): Fix type errors and remove excludes.
|
|
|
|
|
"src/commands/mcp.test.ts",
|
|
|
|
|
"src/commands/mcp/add.test.ts",
|
|
|
|
|
"src/commands/mcp/list.test.ts",
|
|
|
|
|
"src/commands/mcp/remove.test.ts",
|
2026-03-16 23:25:33 +08:00
|
|
|
"src/commands/mcp/reconnect.test.ts",
|
2025-08-14 10:35:34 -07:00
|
|
|
"src/config/config.integration.test.ts",
|
|
|
|
|
"src/config/config.test.ts",
|
|
|
|
|
"src/config/extension.test.ts",
|
|
|
|
|
"src/config/settings.test.ts",
|
|
|
|
|
"src/nonInteractiveCli.test.ts",
|
|
|
|
|
"src/services/FileCommandLoader.test.ts",
|
|
|
|
|
"src/services/prompt-processors/argumentProcessor.test.ts",
|
2026-05-18 00:01:47 +08:00
|
|
|
"src/serve/auth.test.ts",
|
2026-05-15 15:21:25 +08:00
|
|
|
"src/serve/server.test.ts",
|
2025-08-14 10:35:34 -07:00
|
|
|
"src/utils/cleanup.test.ts",
|
|
|
|
|
"src/utils/handleAutoUpdate.test.ts",
|
|
|
|
|
"src/utils/startupWarnings.test.ts",
|
|
|
|
|
"src/ui/App.test.tsx",
|
|
|
|
|
"src/ui/commands/aboutCommand.test.ts",
|
|
|
|
|
"src/ui/commands/authCommand.test.ts",
|
|
|
|
|
"src/ui/commands/bugCommand.test.ts",
|
|
|
|
|
"src/ui/commands/clearCommand.test.ts",
|
|
|
|
|
"src/ui/commands/compressCommand.test.ts",
|
|
|
|
|
"src/ui/commands/copyCommand.test.ts",
|
|
|
|
|
"src/ui/commands/docsCommand.test.ts",
|
|
|
|
|
"src/ui/commands/editorCommand.test.ts",
|
|
|
|
|
"src/ui/commands/extensionsCommand.test.ts",
|
|
|
|
|
"src/ui/commands/helpCommand.test.ts",
|
|
|
|
|
"src/ui/commands/restoreCommand.test.ts",
|
|
|
|
|
"src/ui/commands/settingsCommand.test.ts",
|
|
|
|
|
"src/ui/commands/themeCommand.test.ts",
|
|
|
|
|
"src/ui/commands/chatCommand.test.ts",
|
|
|
|
|
"src/ui/commands/directoryCommand.test.tsx",
|
|
|
|
|
"src/ui/commands/ideCommand.test.ts",
|
|
|
|
|
"src/ui/commands/initCommand.test.ts",
|
|
|
|
|
"src/ui/commands/quitCommand.test.ts",
|
|
|
|
|
"src/ui/commands/mcpCommand.test.ts",
|
|
|
|
|
"src/ui/commands/memoryCommand.test.ts",
|
|
|
|
|
"src/ui/commands/statsCommand.test.ts",
|
|
|
|
|
"src/ui/commands/terminalSetupCommand.test.ts",
|
|
|
|
|
"src/ui/commands/toolsCommand.test.ts",
|
|
|
|
|
"src/ui/components/ContextSummaryDisplay.test.tsx",
|
|
|
|
|
"src/ui/components/Footer.test.tsx",
|
|
|
|
|
"src/ui/components/InputPrompt.test.tsx",
|
|
|
|
|
"src/ui/components/ModelStatsDisplay.test.tsx",
|
|
|
|
|
"src/ui/components/SessionSummaryDisplay.test.tsx",
|
|
|
|
|
"src/ui/components/shared/text-buffer.test.ts",
|
|
|
|
|
"src/ui/components/shared/vim-buffer-actions.test.ts",
|
|
|
|
|
"src/ui/components/StatsDisplay.test.tsx",
|
|
|
|
|
"src/ui/components/ToolStatsDisplay.test.tsx",
|
2025-10-23 09:27:04 +08:00
|
|
|
"src/ui/components/WarningMessage.test.tsx",
|
2025-08-14 10:35:34 -07:00
|
|
|
"src/ui/contexts/SessionContext.test.tsx",
|
|
|
|
|
"src/ui/hooks/slashCommandProcessor.test.ts",
|
|
|
|
|
"src/ui/hooks/useAtCompletion.test.ts",
|
|
|
|
|
"src/ui/hooks/useConsoleMessages.test.ts",
|
|
|
|
|
"src/ui/hooks/useCommandCompletion.test.ts",
|
|
|
|
|
"src/ui/hooks/useFocus.test.ts",
|
|
|
|
|
"src/ui/hooks/useFolderTrust.test.ts",
|
|
|
|
|
"src/ui/hooks/useGeminiStream.test.tsx",
|
|
|
|
|
"src/ui/hooks/useKeypress.test.ts",
|
|
|
|
|
"src/ui/hooks/usePhraseCycler.test.ts",
|
|
|
|
|
"src/ui/hooks/vim.test.ts",
|
|
|
|
|
"src/ui/utils/computeStats.test.ts",
|
|
|
|
|
"src/ui/themes/theme.test.ts",
|
|
|
|
|
"src/validateNonInterActiveAuth.test.ts",
|
2025-10-23 09:27:04 +08:00
|
|
|
"src/services/prompt-processors/shellProcessor.test.ts",
|
|
|
|
|
"src/commands/extensions/examples/**"
|
2025-07-07 23:41:39 -07:00
|
|
|
],
|
2026-03-27 08:29:21 +00:00
|
|
|
"references": [
|
|
|
|
|
{ "path": "../core" },
|
refactor(acp-bridge): create skeleton + lift zero-coupling primitives (#4175 PR 22a) (#4295)
* refactor(acp-bridge): create skeleton + lift zero-coupling primitives (#4175 PR 22a)
First slice of #4175 Wave 5 PR 22 (`refactor(serve): extract acp bridge
primitives`). Lifts the three primitives from `packages/cli/src/serve/`
that have zero coupling to the rest of `serve/`, so PR 22a can land
ahead of PR 17 (#4282) and PR 14b (#4271) without merge-conflict risk
on `httpAcpBridge.ts`. Also seeds the `PermissionMediator` interface
contract that PR 24 will implement (4 strategies — first-responder /
designated / consensus / local-only — replacing the inline
first-responder voting in `BridgeClient.requestPermission`).
What moves
- `cli/src/serve/eventBus.ts` (578 LOC, no internal imports) →
`packages/acp-bridge/src/eventBus.ts`
- `cli/src/serve/inMemoryChannel.ts` (73 LOC, only depends on
`@agentclientprotocol/sdk`) → `packages/acp-bridge/src/inMemoryChannel.ts`
- `httpAcpBridge.ts:638-677` `AcpChannel` / `AcpChannelExitInfo` /
`ChannelFactory` types → `packages/acp-bridge/src/channel.ts`
- Both test files moved alongside their sources
What's new
- `packages/acp-bridge/` package (`@qwen-code/acp-bridge`, internal,
not published to npm yet)
- `packages/acp-bridge/src/permission.ts` — type-only
`PermissionMediator` / `PermissionPolicy` / `PermissionResolution`
/ `PermissionRequestRecord` / `PermissionVote` /
`PermissionVoteOutcome`. No implementation; PR 24 fills it in.
- `packages/cli/src/serve/eventBus.ts` and `inMemoryChannel.ts` are
now one-line re-export wrappers for backward compat.
- `httpAcpBridge.ts:638-677` is now a one-line `import type` +
`export type` re-export.
Backward compatibility
- All existing relative imports (`./eventBus.js`,
`./inMemoryChannel.js`, `../serve/eventBus.js`) keep resolving via
the wrappers — no churn for the 8 importer sites in
`cli/src/serve/` plus `cli/src/commands/serve.ts:14`.
- `httpAcpBridge.ts` continues to export `AcpChannel` /
`AcpChannelExitInfo` / `ChannelFactory` so any external consumer
is unaffected.
- Zero `/capabilities` payload changes, zero HTTP route changes,
zero SDK behavior changes, zero spawn-site behavior changes.
What's not in this slice (deferred to PR 22b after PR 17/14b land)
- `BridgeClient` + `createHttpAcpBridge` factory + `defaultSpawnChannelFactory`
(~3000 LOC, lines 1082-3770 + 4106-4307 of `httpAcpBridge.ts`).
- Channel and VSCode-IDE-companion own-spawn migrations.
Tests
- `npm test --workspace @qwen-code/acp-bridge` — 28/28 pass
(eventBus 20 + inMemoryChannel 8) at the new location.
- `cd packages/cli && npx vitest run src/serve/` — 567/567 pass
(no regressions).
- `cd packages/cli && npx tsc --noEmit` clean.
References
- #4175 Wave 5 PR 22 row
- #3803 chiga0's "Stage 1.5-prereq AcpChannel lift"
- `httpAcpBridge.ts:679-696` FIXME for the four `PermissionMediator`
strategies this slice declares
* fix(acp-bridge): minimize package-lock.json diff to acp-bridge entries only
The previous commit ran `npm install --ignore-scripts`, which npm 11
treated as license to renormalize peer-dependency markers across the
entire lockfile and resolve `@types/react@18.3.28`,
`@types/react-dom@18.3.7`, and `@types/prop-types@15.7.15` away from
their pinned versions. CI's `npm ci` then refused to install because
the manifests no longer matched the lockfile.
Restored package-lock.json to origin/main and surgically added only the
three entries the new package actually requires:
- `node_modules/@qwen-code/acp-bridge` workspace symlink
- `packages/acp-bridge` workspace manifest snapshot
- `@qwen-code/acp-bridge` listed under `packages/cli`'s dependencies
`npm ci --no-audit --ignore-scripts` now succeeds (1453 packages, no
warnings about stale lockfile entries). Re-verified `acp-bridge`
package tests (28/28 pass) and `tsc --build` clean.
* fix(acp-bridge): address PR 22a review feedback
Three review-driven fixes:
1. **wenshao**: removed `src/**/*.test.ts` from `tsconfig.json` exclude
so the moved `eventBus.test.ts` and `inMemoryChannel.test.ts`
regain typecheck coverage. Pre-fix, a future change to
`BridgeEvent` / `SubscribeOptions` shape would only fail at
runtime; post-fix `tsc --noEmit` catches the mismatch. Matches
`packages/core/tsconfig.json`'s pattern (no test exclude;
emitted test artefacts in dist/ are accepted convention).
2. **Copilot**: corrected the FIXME line citation in
`permission.ts` and `README.md` from `1144-1154` to the actual
range `1096-1106` (the four-strategy FIXME inside
`BridgeClient.requestPermission`). Verified via grep against
current `httpAcpBridge.ts`.
3. **Copilot review summary**: added a "Imports — root vs subpaths"
section to README.md explaining when to use the barrel root
(`@qwen-code/acp-bridge`) vs per-module subpaths
(`/eventBus`, `/inMemoryChannel`, `/channel`, `/permission`),
and added `@see` JSDoc pointers in `cli/src/serve/eventBus.ts`
and `inMemoryChannel.ts` wrappers to the implementation files
for the design-rationale comments that moved to acp-bridge.
Verification: 28/28 acp-bridge tests + 567/567 cli serve tests
pass; `tsc --noEmit` clean across both packages including the
moved test files.
Declined (replied on the PR):
- Move `@agentclientprotocol/sdk` to `peerDependencies` — sound
advice in general but not yet relevant; package is internal
(`files: ["dist"]`, no npm publish), so dedupe is automatic
through monorepo file: links. Will revisit during PR 28
(npm alpha publish).
2026-05-19 01:23:08 +08:00
|
|
|
{ "path": "../acp-bridge" },
|
2026-03-27 08:29:21 +00:00
|
|
|
{ "path": "../channels/base" },
|
|
|
|
|
{ "path": "../channels/telegram" },
|
|
|
|
|
{ "path": "../channels/weixin" },
|
|
|
|
|
{ "path": "../channels/dingtalk" }
|
|
|
|
|
]
|
2025-04-17 18:06:21 -04:00
|
|
|
}
|