* 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).
Add references to channels packages (base, telegram, weixin, dingtalk)
to enable proper TypeScript project references for the CLI package.
This enables better incremental builds and type checking across the
monorepo's channel packages.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Added a new reconnect command to the MCP CLI.
- Implemented auto-reconnect functionality in DiscoveredMCPToolInvocation to handle connection errors with retry logic.
- Enhanced tests to cover reconnect scenarios and ensure reliability during connection failures.
This change detects the most recent git commit short hash and writes it to the `GIT_COMMIT_INFO` constant in `packages/cli/src/generated/git-commit.sh`, optionally appending the string "(local modifications)" if additional local changes after that commit are detected.
If set, this string is displayed in the `/about` dialog as well as passed into the `/bug` template.
Example:
```
> /about
╭───────────────────────────────────────────────────────────────────────────╮
│ │
│ About Gemini CLI │
│ │
│ CLI Version development │
│ Git Commit 43370ab (local modifications) │
│ Model gemini-2.5-pro-preview-05-06 │
│ Sandbox sandbox-exec (minimal) │
│ OS darwin v23.11.0 │
│ │
╰───────────────────────────────────────────────────────────────────────────╯
```
Additionally, this change updates `.gitignore` to ignore the generated files, `scripts/clean.sh` to remove them, and adds a `npm run generate` stage for this and any other generators we need to write.
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__