feat(agent): add Gemini CLI as an install target#236
Conversation
Adds `gemini` to the supported agent-install targets. Gemini CLI reads project-level context from a GEMINI.md file in the repo root, which is loaded at the start of every session (always-on, no on-demand mode). Because all installed skills share a single GEMINI.md file in the project root, the target uses managed-section mode -- the same approach as the codex/AGENTS.md target -- writing only a sentinel-delimited section so any existing user content in GEMINI.md is never clobbered. The landing path is GEMINI.md (repo root). Both testsprite-verify and testsprite-onboard are aggregated into one managed section, consistent with how codex aggregates skills into AGENTS.md. Slots into the existing TARGETS machinery: agent list, setup --agent, and skill-nudge install-detection all pick it up automatically. Updates the AgentTarget union, pathFor, TARGETS, agent command description, help text, unit tests, e2e matrix guards, and the help snapshot. Contributes to CONTRIBUTING.md accepted target: gemini
WalkthroughGemini is added as a managed-section installation target using ChangesGemini agent target
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant AgentTargets
participant GEMINImd
CLI->>AgentTargets: install target gemini
AgentTargets->>GEMINImd: resolve GEMINI.md
AgentTargets->>GEMINImd: write sentinel-delimited Markdown section
GEMINImd-->>CLI: updated installation content
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/commands/agent.ts`:
- Around line 1073-1075: Update the --force option description in the agent
command to document that both Gemini and Codex use managed sections, while
explicitly preserving the guarantee that user content outside the
managed-section sentinels is never overwritten.
In `@src/lib/agent-targets.ts`:
- Around line 254-276: Update the shared managed-section sentinel used by the
managed-section writer to a target-neutral label instead of “testsprite agent
install codex,” while preserving recognition of the existing Codex marker for
backward compatibility. Locate the sentinel constants and managed-section
parsing/writing logic, and ensure new GEMINI.md and Codex files use the neutral
marker without breaking cleanup or updates of legacy Codex files.
In `@test/e2e/agent-install.e2e.test.ts`:
- Around line 275-304: Add deterministic offline coverage around the existing
Gemini installation test by pre-populating GEMINI.md with user content before
installing both skills, then rerun installation and assert the user content
remains unchanged, exactly one MANAGED_SECTION_BEGIN/END pair exists, and only
the content between those sentinels is replaced. Reuse the existing runCli,
freshTmpDir, TARGETS, and sentinel constants, and compare the preserved
prefix/suffix or expected managed section across runs.
- Around line 275-280: The test `gemini GEMINI.md contains ONE managed section
with verify and onboard content` ignores the CLI result. Capture the `runCli`
return value, assert a zero exit status, parse `stdout` as JSON and validate the
expected response, and assert diagnostics are emitted only on `stderr` before
reading the generated file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4af5ce26-4c1b-4c2a-88ec-1d663051e8a7
⛔ Files ignored due to path filters (1)
test/__snapshots__/help.snapshot.test.ts.snapis excluded by!**/*.snap,!**/*.snap
📒 Files selected for processing (6)
src/commands/agent.test.tssrc/commands/agent.tssrc/lib/agent-targets.test.tssrc/lib/agent-targets.tstest/e2e/agent-install.e2e.test.tstest/e2e/setup.e2e.test.ts
| .option( | ||
| '--target <t>', | ||
| 'Agent target(s): claude, cursor, cline, antigravity, kiro, windsurf, copilot, codex (comma-separated or repeated)', | ||
| 'Agent target(s): claude, cursor, cline, antigravity, kiro, windsurf, copilot, gemini, codex (comma-separated or repeated)', |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Document Gemini in the managed-section --force behavior.
The target help includes gemini, but the existing --force description still says only codex is managed-section. Update it to mention both targets or all managed-section targets, while retaining the no-clobber guarantee.
As per path instructions, managed-section targets’ user content outside the sentinels must remain explicitly protected.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/commands/agent.ts` around lines 1073 - 1075, Update the --force option
description in the agent command to document that both Gemini and Codex use
managed sections, while explicitly preserving the guarantee that user content
outside the managed-section sentinels is never overwritten.
Source: Path instructions
| /** | ||
| * gemini target -- managed-section mode (GEMINI.md). | ||
| * | ||
| * Gemini CLI reads project-level instructions from a `GEMINI.md` file in | ||
| * the repo root. The file is plain Markdown, loaded at the start of every | ||
| * session (always-on). Because all installed skills share this single file | ||
| * we use managed-section mode -- the same approach as codex/AGENTS.md -- | ||
| * writing only a sentinel-delimited section so any existing user content | ||
| * in GEMINI.md is never clobbered. | ||
| * | ||
| * The compact body is used (same reasoning as windsurf/copilot): GEMINI.md | ||
| * is always-injected, so keeping it small reduces context cost. | ||
| * | ||
| * --force replaces the managed section unconditionally but never touches | ||
| * content outside the sentinels. | ||
| */ | ||
| gemini: { | ||
| status: 'experimental', | ||
| path: pathFor('gemini', SKILL_NAME), | ||
| mode: 'managed-section', | ||
| // GEMINI.md is plain Markdown; wrap is a no-op (no frontmatter). | ||
| wrap: (_name, _description, body) => body, | ||
| }, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use a target-neutral managed-section sentinel.
Gemini uses the shared managed-section writer, but MANAGED_SECTION_BEGIN currently says testsprite agent install codex. A generated GEMINI.md will therefore label its managed content as Codex, which is misleading for users and future cleanup tooling. Rename the shared marker to be target-neutral while preserving compatibility with existing Codex files.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/agent-targets.ts` around lines 254 - 276, Update the shared
managed-section sentinel used by the managed-section writer to a target-neutral
label instead of “testsprite agent install codex,” while preserving recognition
of the existing Codex marker for backward compatibility. Locate the sentinel
constants and managed-section parsing/writing logic, and ensure new GEMINI.md
and Codex files use the neutral marker without breaking cleanup or updates of
legacy Codex files.
| it('gemini GEMINI.md contains ONE managed section with verify and onboard content', () => { | ||
| const tmpDir = freshTmpDir(); | ||
| runCli(['agent', 'install', '--target=gemini', '--dir', tmpDir, '--output', 'json']); | ||
|
|
||
| const filePath = join(tmpDir, TARGETS.gemini.path); | ||
| const content = readFileSync(filePath, 'utf8'); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Assert the CLI exit code and JSON output.
The runCli result is ignored, so a failed install that leaves a readable file could still let this test pass. Assert a zero exit status, parse stdout as JSON, and verify diagnostics remain on stderr.
As per path instructions, tests must cover exit-code paths and preserve machine-readable JSON output discipline.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/e2e/agent-install.e2e.test.ts` around lines 275 - 280, The test `gemini
GEMINI.md contains ONE managed section with verify and onboard content` ignores
the CLI result. Capture the `runCli` return value, assert a zero exit status,
parse `stdout` as JSON and validate the expected response, and assert
diagnostics are emitted only on `stderr` before reading the generated file.
Source: Path instructions
| it('gemini GEMINI.md contains ONE managed section with verify and onboard content', () => { | ||
| const tmpDir = freshTmpDir(); | ||
| runCli(['agent', 'install', '--target=gemini', '--dir', tmpDir, '--output', 'json']); | ||
|
|
||
| const filePath = join(tmpDir, TARGETS.gemini.path); | ||
| const content = readFileSync(filePath, 'utf8'); | ||
|
|
||
| // (a) Exactly ONE pair of sentinels | ||
| const escRe = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| const beginCount = (content.match(new RegExp(escRe(MANAGED_SECTION_BEGIN), 'g')) ?? []).length; | ||
| const endCount = (content.match(new RegExp(escRe(MANAGED_SECTION_END), 'g')) ?? []).length; | ||
| expect(beginCount, 'exactly one BEGIN sentinel').toBe(1); | ||
| expect(endCount, 'exactly one END sentinel').toBe(1); | ||
|
|
||
| // BEGIN must come before END | ||
| expect(content.indexOf(MANAGED_SECTION_BEGIN)).toBeLessThan( | ||
| content.indexOf(MANAGED_SECTION_END), | ||
| ); | ||
|
|
||
| // (b) Load-bearing command strings from the compact verify body | ||
| expect(content).toContain('testsprite test run'); | ||
| expect(content).toContain('--wait'); | ||
| expect(content).toContain('test artifact get'); | ||
|
|
||
| // (c) Onboard one-liner must be present | ||
| expect(content).toContain('First-time setup'); | ||
|
|
||
| // (d) No frontmatter fence -- GEMINI.md is plain prose | ||
| expect(content.startsWith('---'), 'gemini: must NOT start with ---').toBe(false); | ||
| }); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Cover managed-section preservation and reruns.
This test starts from an empty GEMINI.md and verifies only a single install. Add coverage that pre-populates user content outside the sentinels, installs both skills, then reruns installation and asserts that user content remains intact, exactly one section exists, and only the managed section is replaced.
As per path instructions, tests must cover the new behavior deterministically and offline.
🧰 Tools
🪛 ast-grep (0.44.1)
[warning] 283-283: Do not use variable for regular expressions
Context: new RegExp(escRe(MANAGED_SECTION_BEGIN), 'g')
Note: [CWE-1333] Inefficient Regular Expression Complexity. Security best practice.
(regexp-non-literal-typescript)
[warning] 284-284: Do not use variable for regular expressions
Context: new RegExp(escRe(MANAGED_SECTION_END), 'g')
Note: [CWE-1333] Inefficient Regular Expression Complexity. Security best practice.
(regexp-non-literal-typescript)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/e2e/agent-install.e2e.test.ts` around lines 275 - 304, Add deterministic
offline coverage around the existing Gemini installation test by pre-populating
GEMINI.md with user content before installing both skills, then rerun
installation and assert the user content remains unchanged, exactly one
MANAGED_SECTION_BEGIN/END pair exists, and only the content between those
sentinels is replaced. Reuse the existing runCli, freshTmpDir, TARGETS, and
sentinel constants, and compare the preserved prefix/suffix or expected managed
section across runs.
Source: Path instructions
Summary
CONTRIBUTING.md explicitly lists
geminias an accepted, in-progresstarget with no existing PR. This adds it.
Gemini CLI reads project-level instructions from a
GEMINI.mdfile inthe repo root, loaded at the start of every session (always-on, no
on-demand mode). Because all installed skills share a single root file,
the target uses managed-section mode -- the same approach as the
codex/AGENTS.md target -- writing only a sentinel-delimited section so
existing user content in GEMINI.md is never clobbered.
Changes
src/lib/agent-targets.ts-- AddedgeminitoAgentTargetunion,GEMINI.mdcase inpathFor, and ageminientry inTARGETSusingmanaged-sectionmode.src/lib/agent-targets.test.ts-- Updated key count, experimentalstatus, managed-section assertions, and a dedicated
renderForTarget("gemini")describe block.src/commands/agent.ts-- Updated command description and--targethelp text to include gemini.
src/commands/agent.test.ts-- UpdatedrunListrow count to reflectthe new target.
test/e2e/agent-install.e2e.test.ts-- Updated matrix guard, addedgemini content assertions, added dedicated GEMINI.md managed-section
test.
test/e2e/setup.e2e.test.ts-- Updated matrix guard.test/__snapshots__/help.snapshot.test.ts.snap-- Updated 4 snapshots.Design decisions
testsprite-verifyandtestsprite-onboardresolve to the sameGEMINI.mdpath. Usingown-file mode causes a conflict error on the second skill write.
managed-section aggregates all skills into one sentinel-delimited
block, consistent with how codex handles AGENTS.md.
is a no-op, matching codex.
Tests
All 1865 tests pass. Coverage stays above 80%.
Closes #235
Summary by CodeRabbit
New Features
GEMINI.mdusing plain Markdown and managed sections.Tests