* feat(channels): add Feishu (Lark) channel adapter
* fix(channels/feishu): fix webhook stop button, memory leak, spin-wait timeout, and reaction cleanup
* fix(channels/feishu): fix security, stability and build issues from PR review
* fix(channels/feishu): fix card lifecycle, streaming limits, and download safety from CR round 2
* fix(channels/feishu): harden webhook, card lifecycle, and disconnect cleanup from CR round 3
* fix(feishu): clarify stoppedMessages JSDoc to match actual cleanup behavior
* fix(channels/feishu): handle post messages without language key wrapper in quote context
* fix(channels/feishu): fix webhook signature bypass, stop-button double-send, and blockStreaming duplicates from CR round 4
* fix(channels/feishu): harden card lifecycle, markdown splitting, and defensive guards from CR round 5
* fix(channels/feishu): harden card lifecycle, markdown splitting, and defensive guards from CR round 5
- Set cardCreationFailed on onPromptStart failure to prevent retry spiral
- Skip throttle updates when card creation permanently failed
- Handle code fences in hard-split and table-stripping fallbacks
- Use parity-based fence detection in splitByTables (align with splitChunks)
- Add cs.stopped and else branch in onPromptEnd to prevent timer race and state leak
- Mark cardState.stopped after busy-wait timeout to abandon orphaned in-flight creation
- Apply MAX_CARD_CHARS truncation with fence parity in onResponseComplete
- Sanitize senderId before <at> tag interpolation
- Use replaceAll + callback form for mention replacement
- Floor token expiry to prevent thundering herd on expire:0
- Add log for stop-button auth rejection
- Fix stoppedMessages JSDoc to match actual cleanup lifecycle
- Fix test fixture to match "still creating" scenario
- Fix typecheck errors in test file (TS2571, TS4111)
- Add stop-button auth negative path tests (operator mismatch, missing operator, missing sender)
- Replace spanning regex in table-stripping with line-by-line stripTables() to resolve CodeQL ReDoS warning
* fix(channels/feishu): fix HMAC bypass, prompt injection, SSRF, and card lifecycle from CR round 5-6
Security:
- Fix webhook HMAC bypass: use defineProperty(non-enumerable) for headers instead of prototype shadowing
- Fix cross-user prompt injection: mark quoted content as untrusted with explicit marker
- Fix SSRF: validate all Feishu IDs with FEISHU_ID_RE before URL interpolation in 6 endpoints
- Fix safeSenderId regex: add hyphen to character class so ou_abc-def-123 is not rejected
Card lifecycle:
- Set cardCreationFailed on onPromptStart failure to prevent retry spiral
- Skip throttle updates when card creation permanently failed
- Fallback to plain message delivery when cardCreationFailed with accumulated text
- Track creationTimer in CardSessionState so cleanupCard/disconnect can cancel orphaned card creation
- Add cs.stopped and else branch in onPromptEnd to prevent timer race and state leak
- Mark cardState.stopped after busy-wait timeout to abandon orphaned in-flight creation
- Apply MAX_CARD_CHARS truncation with fence parity in onResponseComplete
- Preserve atPrefix in streaming truncation to prevent @mention visual snap
- Account for suffix and fence reserve in truncation maxBody calculation
- Clean up auxiliary maps after handleInbound when gate rejects the message
- Clean up blockStreaming mode Map entries in onPromptEnd
- Skip bare @mention without question text
Markdown:
- Handle code fences in hard-split and table-stripping fallbacks
- Use parity-based fence detection in splitByTables (align with splitChunks)
- Replace spanning regex in table-stripping with line-by-line stripTables() to resolve CodeQL ReDoS warning
Defensive guards:
- Sanitize senderId before <at> tag interpolation
- Use replaceAll + callback form for mention replacement
- Floor token expiry to prevent thundering herd on expire:0
- Add log for stop-button auth rejection
Tests:
- Fix stoppedMessages JSDoc to match actual cleanup lifecycle
- Fix test fixture to match "still creating" scenario
- Fix typecheck errors in test file (TS2571, TS4111)
- Add stop-button auth negative path tests (operator mismatch, missing operator, missing sender)
- Assert cancelSession called in stop-button happy-path test
* fix(channels/feishu): add request timeouts, token dedup, and harden file/quote sanitization
* fix(channels/feishu): harden card lifecycle, webhook auth, and resource cleanup from CR round 7
* fix(channels/feishu): harden card lifecycle, mention handling, and error recovery
* 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__