@dgxo/mashadevcli 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +393 -0
- package/bundle/builtin/skill-creator/SKILL.md +382 -0
- package/bundle/builtin/skill-creator/scripts/init_skill.cjs +239 -0
- package/bundle/builtin/skill-creator/scripts/package_skill.cjs +131 -0
- package/bundle/builtin/skill-creator/scripts/validate_skill.cjs +131 -0
- package/bundle/docs/CONTRIBUTING.md +1 -0
- package/bundle/docs/admin/enterprise-controls.md +115 -0
- package/bundle/docs/assets/connected_devtools.png +0 -0
- package/bundle/docs/assets/gemini-screenshot.png +0 -0
- package/bundle/docs/assets/monitoring-dashboard-logs.png +0 -0
- package/bundle/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/bundle/docs/assets/monitoring-dashboard-overview.png +0 -0
- package/bundle/docs/assets/release_patch.png +0 -0
- package/bundle/docs/assets/theme-ansi-light.png +0 -0
- package/bundle/docs/assets/theme-ansi.png +0 -0
- package/bundle/docs/assets/theme-atom-one.png +0 -0
- package/bundle/docs/assets/theme-ayu-light.png +0 -0
- package/bundle/docs/assets/theme-ayu.png +0 -0
- package/bundle/docs/assets/theme-custom.png +0 -0
- package/bundle/docs/assets/theme-default-light.png +0 -0
- package/bundle/docs/assets/theme-default.png +0 -0
- package/bundle/docs/assets/theme-dracula.png +0 -0
- package/bundle/docs/assets/theme-github-light.png +0 -0
- package/bundle/docs/assets/theme-github.png +0 -0
- package/bundle/docs/assets/theme-google-light.png +0 -0
- package/bundle/docs/assets/theme-xcode-light.png +0 -0
- package/bundle/docs/changelogs/index.md +867 -0
- package/bundle/docs/changelogs/latest.md +208 -0
- package/bundle/docs/changelogs/preview.md +187 -0
- package/bundle/docs/cli/checkpointing.md +93 -0
- package/bundle/docs/cli/cli-reference.md +115 -0
- package/bundle/docs/cli/creating-skills.md +80 -0
- package/bundle/docs/cli/custom-commands.md +327 -0
- package/bundle/docs/cli/enterprise.md +604 -0
- package/bundle/docs/cli/gemini-ignore.md +71 -0
- package/bundle/docs/cli/gemini-md.md +116 -0
- package/bundle/docs/cli/generation-settings.md +210 -0
- package/bundle/docs/cli/headless.md +50 -0
- package/bundle/docs/cli/model-routing.md +42 -0
- package/bundle/docs/cli/model.md +53 -0
- package/bundle/docs/cli/plan-mode.md +375 -0
- package/bundle/docs/cli/rewind.md +51 -0
- package/bundle/docs/cli/sandbox.md +257 -0
- package/bundle/docs/cli/session-management.md +184 -0
- package/bundle/docs/cli/settings.md +165 -0
- package/bundle/docs/cli/skills.md +134 -0
- package/bundle/docs/cli/system-prompt.md +125 -0
- package/bundle/docs/cli/telemetry.md +922 -0
- package/bundle/docs/cli/themes.md +269 -0
- package/bundle/docs/cli/token-caching.md +20 -0
- package/bundle/docs/cli/trusted-folders.md +126 -0
- package/bundle/docs/cli/tutorials/automation.md +283 -0
- package/bundle/docs/cli/tutorials/file-management.md +142 -0
- package/bundle/docs/cli/tutorials/mcp-setup.md +113 -0
- package/bundle/docs/cli/tutorials/memory-management.md +126 -0
- package/bundle/docs/cli/tutorials/session-management.md +105 -0
- package/bundle/docs/cli/tutorials/shell-commands.md +107 -0
- package/bundle/docs/cli/tutorials/skills-getting-started.md +110 -0
- package/bundle/docs/cli/tutorials/task-planning.md +93 -0
- package/bundle/docs/cli/tutorials/web-tools.md +78 -0
- package/bundle/docs/core/index.md +107 -0
- package/bundle/docs/core/remote-agents.md +84 -0
- package/bundle/docs/core/subagents.md +307 -0
- package/bundle/docs/examples/proxy-script.md +83 -0
- package/bundle/docs/extensions/best-practices.md +188 -0
- package/bundle/docs/extensions/index.md +61 -0
- package/bundle/docs/extensions/reference.md +333 -0
- package/bundle/docs/extensions/releasing.md +154 -0
- package/bundle/docs/extensions/writing-extensions.md +308 -0
- package/bundle/docs/get-started/authentication.md +402 -0
- package/bundle/docs/get-started/examples.md +139 -0
- package/bundle/docs/get-started/gemini-3.md +115 -0
- package/bundle/docs/get-started/index.md +82 -0
- package/bundle/docs/get-started/installation.md +174 -0
- package/bundle/docs/hooks/best-practices.md +709 -0
- package/bundle/docs/hooks/index.md +164 -0
- package/bundle/docs/hooks/reference.md +330 -0
- package/bundle/docs/hooks/writing-hooks.md +474 -0
- package/bundle/docs/ide-integration/ide-companion-spec.md +267 -0
- package/bundle/docs/ide-integration/index.md +224 -0
- package/bundle/docs/index.md +141 -0
- package/bundle/docs/integration-tests.md +211 -0
- package/bundle/docs/issue-and-pr-automation.md +172 -0
- package/bundle/docs/local-development.md +134 -0
- package/bundle/docs/mermaid/context.mmd +103 -0
- package/bundle/docs/mermaid/render-path.mmd +64 -0
- package/bundle/docs/npm.md +62 -0
- package/bundle/docs/redirects.json +20 -0
- package/bundle/docs/reference/commands.md +526 -0
- package/bundle/docs/reference/configuration.md +1786 -0
- package/bundle/docs/reference/keyboard-shortcuts.md +164 -0
- package/bundle/docs/reference/memport.md +246 -0
- package/bundle/docs/reference/policy-engine.md +364 -0
- package/bundle/docs/reference/tools.md +106 -0
- package/bundle/docs/release-confidence.md +164 -0
- package/bundle/docs/releases.md +540 -0
- package/bundle/docs/resources/faq.md +175 -0
- package/bundle/docs/resources/quota-and-pricing.md +165 -0
- package/bundle/docs/resources/tos-privacy.md +102 -0
- package/bundle/docs/resources/troubleshooting.md +176 -0
- package/bundle/docs/resources/uninstall.md +56 -0
- package/bundle/docs/sidebar.json +233 -0
- package/bundle/docs/tools/activate-skill.md +43 -0
- package/bundle/docs/tools/ask-user.md +95 -0
- package/bundle/docs/tools/file-system.md +129 -0
- package/bundle/docs/tools/internal-docs.md +46 -0
- package/bundle/docs/tools/mcp-server.md +1150 -0
- package/bundle/docs/tools/memory.md +35 -0
- package/bundle/docs/tools/planning.md +58 -0
- package/bundle/docs/tools/shell.md +216 -0
- package/bundle/docs/tools/todos.md +35 -0
- package/bundle/docs/tools/web-fetch.md +35 -0
- package/bundle/docs/tools/web-search.md +32 -0
- package/bundle/docs/update/update-guide.md +111 -0
- package/bundle/masha.js +563471 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/client/main.js +89 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.d.ts +7 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js +9 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/_client-assets.js.map +1 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.d.ts +48 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js +299 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/index.js.map +1 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.d.ts +36 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js +7 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/dist/src/types.js.map +1 -0
- package/bundle/node_modules/@dgxo/mashadevcli-devtools/package.json +32 -0
- package/bundle/policies/conseca.toml +6 -0
- package/bundle/policies/discovered.toml +8 -0
- package/bundle/policies/plan.toml +109 -0
- package/bundle/policies/read-only.toml +53 -0
- package/bundle/policies/write.toml +80 -0
- package/bundle/policies/yolo.toml +54 -0
- package/bundle/sandbox-macos-permissive-open.sb +27 -0
- package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
- package/bundle/sandbox-macos-restrictive-open.sb +96 -0
- package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
- package/bundle/sandbox-macos-strict-open.sb +131 -0
- package/bundle/sandbox-macos-strict-proxied.sb +133 -0
- package/package.json +169 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Release extensions
|
|
2
|
+
|
|
3
|
+
Release Gemini CLI extensions to your users through a Git repository or GitHub
|
|
4
|
+
Releases.
|
|
5
|
+
|
|
6
|
+
Git repository releases are the simplest approach and offer the most flexibility
|
|
7
|
+
for managing development branches. GitHub Releases are more efficient for
|
|
8
|
+
initial installations because they ship as single archives rather than requiring
|
|
9
|
+
a full `git clone`. Use GitHub Releases if you need to include platform-specific
|
|
10
|
+
binary files.
|
|
11
|
+
|
|
12
|
+
## List your extension in the gallery
|
|
13
|
+
|
|
14
|
+
The [Gemini CLI extension gallery](https://geminicli.com/extensions/browse/)
|
|
15
|
+
automatically indexes public extensions to help users discover your work. You
|
|
16
|
+
don't need to submit an issue or email us to list your extension.
|
|
17
|
+
|
|
18
|
+
To have your extension automatically discovered and listed:
|
|
19
|
+
|
|
20
|
+
1. **Use a public repository:** Ensure your extension is hosted in a public
|
|
21
|
+
GitHub repository.
|
|
22
|
+
2. **Add the GitHub topic:** Add the `gemini-cli-extension` topic to your
|
|
23
|
+
repository's **About** section. Our crawler uses this topic to find new
|
|
24
|
+
extensions.
|
|
25
|
+
3. **Place the manifest at the root:** Ensure your `gemini-extension.json` file
|
|
26
|
+
is in the absolute root of the repository or the release archive.
|
|
27
|
+
|
|
28
|
+
Our system crawls tagged repositories daily. Once you tag your repository, your
|
|
29
|
+
extension will appear in the gallery if it passes validation.
|
|
30
|
+
|
|
31
|
+
## Release through a Git repository
|
|
32
|
+
|
|
33
|
+
Releasing through Git is the most flexible option. Create a public Git
|
|
34
|
+
repository and provide the URL to your users. They can then install your
|
|
35
|
+
extension using `gemini extensions install <your-repo-uri>`.
|
|
36
|
+
|
|
37
|
+
Users can optionally depend on a specific branch, tag, or commit using the
|
|
38
|
+
`--ref` argument. For example:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
gemini extensions install <your-repo-uri> --ref=stable
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Whenever you push commits to the referenced branch, the CLI prompts users to
|
|
45
|
+
update their installation. The `HEAD` commit is always treated as the latest
|
|
46
|
+
version.
|
|
47
|
+
|
|
48
|
+
### Manage release channels
|
|
49
|
+
|
|
50
|
+
You can use branches or tags to manage different release channels, such as
|
|
51
|
+
`stable`, `preview`, or `dev`.
|
|
52
|
+
|
|
53
|
+
We recommend using your default branch as the stable release channel. This
|
|
54
|
+
ensures that the default installation command always provides the most reliable
|
|
55
|
+
version of your extension. You can then use a `dev` branch for active
|
|
56
|
+
development and merge it into the default branch when you are ready for a
|
|
57
|
+
release.
|
|
58
|
+
|
|
59
|
+
## Release through GitHub Releases
|
|
60
|
+
|
|
61
|
+
Distributing extensions through
|
|
62
|
+
[GitHub Releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases)
|
|
63
|
+
provides a faster installation experience by avoiding a repository clone.
|
|
64
|
+
|
|
65
|
+
Gemini CLI checks for updates by looking for the **Latest** release on GitHub.
|
|
66
|
+
Users can also install specific versions using the `--ref` argument with a
|
|
67
|
+
release tag. Use the `--pre-release` flag to install the latest version even if
|
|
68
|
+
it isn't marked as **Latest**.
|
|
69
|
+
|
|
70
|
+
### Custom pre-built archives
|
|
71
|
+
|
|
72
|
+
You can attach custom archives directly to your GitHub Release as assets. This
|
|
73
|
+
is useful if your extension requires a build step or includes platform-specific
|
|
74
|
+
binaries.
|
|
75
|
+
|
|
76
|
+
Custom archives must be fully self-contained and follow the required
|
|
77
|
+
[archive structure](#archive-structure). If your extension is
|
|
78
|
+
platform-independent, provide a single generic asset.
|
|
79
|
+
|
|
80
|
+
#### Platform-specific archives
|
|
81
|
+
|
|
82
|
+
To let Gemini CLI find the correct asset for a user's platform, use the
|
|
83
|
+
following naming convention:
|
|
84
|
+
|
|
85
|
+
1. **Platform and architecture-specific:**
|
|
86
|
+
`{platform}.{arch}.{name}.{extension}`
|
|
87
|
+
2. **Platform-specific:** `{platform}.{name}.{extension}`
|
|
88
|
+
3. **Generic:** A single asset will be used as a fallback if no specific match
|
|
89
|
+
is found.
|
|
90
|
+
|
|
91
|
+
Use these values for the placeholders:
|
|
92
|
+
|
|
93
|
+
- `{name}`: Your extension name.
|
|
94
|
+
- `{platform}`: Use `darwin` (macOS), `linux`, or `win32` (Windows).
|
|
95
|
+
- `{arch}`: Use `x64` or `arm64`.
|
|
96
|
+
- `{extension}`: Use `.tar.gz` or `.zip`.
|
|
97
|
+
|
|
98
|
+
**Examples:**
|
|
99
|
+
|
|
100
|
+
- `darwin.arm64.my-tool.tar.gz` (specific to Apple Silicon Macs)
|
|
101
|
+
- `darwin.my-tool.tar.gz` (fallback for all Macs, e.g. Intel)
|
|
102
|
+
- `linux.x64.my-tool.tar.gz`
|
|
103
|
+
- `win32.my-tool.zip`
|
|
104
|
+
|
|
105
|
+
#### Archive structure
|
|
106
|
+
|
|
107
|
+
Archives must be fully contained extensions. The `gemini-extension.json` file
|
|
108
|
+
must be at the root of the archive. The rest of the layout should match a
|
|
109
|
+
standard extension structure.
|
|
110
|
+
|
|
111
|
+
#### Example GitHub Actions workflow
|
|
112
|
+
|
|
113
|
+
Use this example workflow to build and release your extension for multiple
|
|
114
|
+
platforms:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
name: Release Extension
|
|
118
|
+
|
|
119
|
+
on:
|
|
120
|
+
push:
|
|
121
|
+
tags:
|
|
122
|
+
- 'v*'
|
|
123
|
+
|
|
124
|
+
jobs:
|
|
125
|
+
release:
|
|
126
|
+
runs-on: ubuntu-latest
|
|
127
|
+
steps:
|
|
128
|
+
- uses: actions/checkout@v3
|
|
129
|
+
|
|
130
|
+
- name: Set up Node.js
|
|
131
|
+
uses: actions/setup-node@v3
|
|
132
|
+
with:
|
|
133
|
+
node-version: '20'
|
|
134
|
+
|
|
135
|
+
- name: Install dependencies
|
|
136
|
+
run: npm ci
|
|
137
|
+
|
|
138
|
+
- name: Build extension
|
|
139
|
+
run: npm run build
|
|
140
|
+
|
|
141
|
+
- name: Create release assets
|
|
142
|
+
run: |
|
|
143
|
+
npm run package -- --platform=darwin --arch=arm64
|
|
144
|
+
npm run package -- --platform=linux --arch=x64
|
|
145
|
+
npm run package -- --platform=win32 --arch=x64
|
|
146
|
+
|
|
147
|
+
- name: Create GitHub Release
|
|
148
|
+
uses: softprops/action-gh-release@v1
|
|
149
|
+
with:
|
|
150
|
+
files: |
|
|
151
|
+
release/darwin.arm64.my-tool.tar.gz
|
|
152
|
+
release/linux.arm64.my-tool.tar.gz
|
|
153
|
+
release/win32.arm64.my-tool.zip
|
|
154
|
+
```
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# Build Gemini CLI extensions
|
|
2
|
+
|
|
3
|
+
Gemini CLI extensions let you expand the capabilities of Gemini CLI by adding
|
|
4
|
+
custom tools, commands, and context. This guide walks you through creating your
|
|
5
|
+
first extension, from setting up a template to adding custom functionality and
|
|
6
|
+
linking it for local development.
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
Before you start, ensure you have the Gemini CLI installed and a basic
|
|
11
|
+
understanding of Node.js.
|
|
12
|
+
|
|
13
|
+
## Extension features
|
|
14
|
+
|
|
15
|
+
Extensions offer several ways to customize Gemini CLI. Use this table to decide
|
|
16
|
+
which features your extension needs.
|
|
17
|
+
|
|
18
|
+
| Feature | What it is | When to use it | Invoked by |
|
|
19
|
+
| :------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
|
|
20
|
+
| **[MCP server](reference.md#mcp-servers)** | A standard way to expose new tools and data sources to the model. | Use this when you want the model to be able to _do_ new things, like fetching data from an internal API, querying a database, or controlling a local application. We also support MCP resources (which can replace custom commands) and system instructions (which can replace custom context) | Model |
|
|
21
|
+
| **[Custom commands](../cli/custom-commands.md)** | A shortcut (like `/my-cmd`) that executes a pre-defined prompt or shell command. | Use this for repetitive tasks or to save long, complex prompts that you use frequently. Great for automation. | User |
|
|
22
|
+
| **[Context file (`GEMINI.md`)](reference.md#contextfilename)** | A markdown file containing instructions that are loaded into the model's context at the start of every session. | Use this to define the "personality" of your extension, set coding standards, or provide essential knowledge that the model should always have. | CLI provides to model |
|
|
23
|
+
| **[Agent skills](../cli/skills.md)** | A specialized set of instructions and workflows that the model activates only when needed. | Use this for complex, occasional tasks (like "create a PR" or "audit security") to avoid cluttering the main context window when the skill isn't being used. | Model |
|
|
24
|
+
| **[Hooks](../hooks/index.md)** | A way to intercept and customize the CLI's behavior at specific lifecycle events (e.g., before/after a tool call). | Use this when you want to automate actions based on what the model is doing, like validating tool arguments, logging activity, or modifying the model's input/output. | CLI |
|
|
25
|
+
| **[Custom themes](reference.md#themes)** | A set of color definitions to personalize the CLI UI. | Use this to provide a unique visual identity for your extension or to offer specialized high-contrast or thematic color schemes. | User (via /theme) |
|
|
26
|
+
|
|
27
|
+
## Step 1: Create a new extension
|
|
28
|
+
|
|
29
|
+
The easiest way to start is by using a built-in template. We'll use the
|
|
30
|
+
`mcp-server` example as our foundation.
|
|
31
|
+
|
|
32
|
+
Run the following command to create a new directory called `my-first-extension`
|
|
33
|
+
with the template files:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
gemini extensions new my-first-extension mcp-server
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This creates a directory with the following structure:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
my-first-extension/
|
|
43
|
+
├── example.js
|
|
44
|
+
├── gemini-extension.json
|
|
45
|
+
└── package.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Step 2: Understand the extension files
|
|
49
|
+
|
|
50
|
+
Your new extension contains several key files that define its behavior.
|
|
51
|
+
|
|
52
|
+
### `gemini-extension.json`
|
|
53
|
+
|
|
54
|
+
The manifest file tells Gemini CLI how to load and use your extension.
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"name": "mcp-server-example",
|
|
59
|
+
"version": "1.0.0",
|
|
60
|
+
"mcpServers": {
|
|
61
|
+
"nodeServer": {
|
|
62
|
+
"command": "node",
|
|
63
|
+
"args": ["${extensionPath}${/}example.js"],
|
|
64
|
+
"cwd": "${extensionPath}"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- `name`: The unique name for your extension.
|
|
71
|
+
- `version`: The version of your extension.
|
|
72
|
+
- `mcpServers`: Defines Model Context Protocol (MCP) servers to add new tools.
|
|
73
|
+
- `command`, `args`, `cwd`: Specify how to start your server. The
|
|
74
|
+
`${extensionPath}` variable is replaced with the absolute path to your
|
|
75
|
+
extension's directory.
|
|
76
|
+
|
|
77
|
+
### `example.js`
|
|
78
|
+
|
|
79
|
+
This file contains the source code for your MCP server. It uses the
|
|
80
|
+
`@modelcontextprotocol/sdk` to define tools.
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
/**
|
|
84
|
+
* @license
|
|
85
|
+
* Copyright 2025 Google LLC
|
|
86
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
90
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
91
|
+
import { z } from 'zod';
|
|
92
|
+
|
|
93
|
+
const server = new McpServer({
|
|
94
|
+
name: 'prompt-server',
|
|
95
|
+
version: '1.0.0',
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Registers a new tool named 'fetch_posts'
|
|
99
|
+
server.registerTool(
|
|
100
|
+
'fetch_posts',
|
|
101
|
+
{
|
|
102
|
+
description: 'Fetches a list of posts from a public API.',
|
|
103
|
+
inputSchema: z.object({}).shape,
|
|
104
|
+
},
|
|
105
|
+
async () => {
|
|
106
|
+
const apiResponse = await fetch(
|
|
107
|
+
'https://jsonplaceholder.typicode.com/posts',
|
|
108
|
+
);
|
|
109
|
+
const posts = await apiResponse.json();
|
|
110
|
+
const response = { posts: posts.slice(0, 5) };
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: 'text',
|
|
115
|
+
text: JSON.stringify(response),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const transport = new StdioServerTransport();
|
|
123
|
+
await server.connect(transport);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### `package.json`
|
|
127
|
+
|
|
128
|
+
The standard configuration file for a Node.js project. It defines dependencies
|
|
129
|
+
and scripts for your extension.
|
|
130
|
+
|
|
131
|
+
## Step 3: Add extension settings
|
|
132
|
+
|
|
133
|
+
Some extensions need configuration, such as API keys or user preferences. Let's
|
|
134
|
+
add a setting for an API key.
|
|
135
|
+
|
|
136
|
+
1. Open `gemini-extension.json`.
|
|
137
|
+
2. Add a `settings` array to the configuration:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"name": "mcp-server-example",
|
|
142
|
+
"version": "1.0.0",
|
|
143
|
+
"settings": [
|
|
144
|
+
{
|
|
145
|
+
"name": "API Key",
|
|
146
|
+
"description": "The API key for the service.",
|
|
147
|
+
"envVar": "MY_SERVICE_API_KEY",
|
|
148
|
+
"sensitive": true
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"mcpServers": {
|
|
152
|
+
// ...
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
When a user installs this extension, Gemini CLI will prompt them to enter the
|
|
158
|
+
"API Key". The value will be stored securely in the system keychain (because
|
|
159
|
+
`sensitive` is true) and injected into the MCP server's process as the
|
|
160
|
+
`MY_SERVICE_API_KEY` environment variable.
|
|
161
|
+
|
|
162
|
+
## Step 4: Link your extension
|
|
163
|
+
|
|
164
|
+
Link your extension to your Gemini CLI installation for local development.
|
|
165
|
+
|
|
166
|
+
1. **Install dependencies:**
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
cd my-first-extension
|
|
170
|
+
npm install
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
2. **Link the extension:**
|
|
174
|
+
|
|
175
|
+
The `link` command creates a symbolic link from the Gemini CLI extensions
|
|
176
|
+
directory to your development directory. Changes you make are reflected
|
|
177
|
+
immediately.
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
gemini extensions link .
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Restart your Gemini CLI session to use the new `fetch_posts` tool. Test it by
|
|
184
|
+
asking: "fetch posts".
|
|
185
|
+
|
|
186
|
+
## Step 5: Add a custom command
|
|
187
|
+
|
|
188
|
+
Custom commands create shortcuts for complex prompts.
|
|
189
|
+
|
|
190
|
+
1. Create a `commands` directory and a subdirectory for your command group:
|
|
191
|
+
|
|
192
|
+
**macOS/Linux**
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
mkdir -p commands/fs
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Windows (PowerShell)**
|
|
199
|
+
|
|
200
|
+
```powershell
|
|
201
|
+
New-Item -ItemType Directory -Force -Path "commands\fs"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
2. Create a file named `commands/fs/grep-code.toml`:
|
|
205
|
+
|
|
206
|
+
```toml
|
|
207
|
+
prompt = """
|
|
208
|
+
Please summarize the findings for the pattern `{{args}}`.
|
|
209
|
+
|
|
210
|
+
Search Results:
|
|
211
|
+
!{grep -r {{args}} .}
|
|
212
|
+
"""
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
This command, `/fs:grep-code`, takes an argument, runs the `grep` shell
|
|
216
|
+
command, and pipes the results into a prompt for summarization.
|
|
217
|
+
|
|
218
|
+
After saving the file, restart Gemini CLI. Run `/fs:grep-code "some pattern"` to
|
|
219
|
+
use your new command.
|
|
220
|
+
|
|
221
|
+
## Step 6: Add a custom `GEMINI.md`
|
|
222
|
+
|
|
223
|
+
Provide persistent context to the model by adding a `GEMINI.md` file to your
|
|
224
|
+
extension. This is useful for setting behavior or providing essential tool
|
|
225
|
+
information.
|
|
226
|
+
|
|
227
|
+
1. Create a file named `GEMINI.md` in the root of your extension directory:
|
|
228
|
+
|
|
229
|
+
```markdown
|
|
230
|
+
# My First Extension Instructions
|
|
231
|
+
|
|
232
|
+
You are an expert developer assistant. When the user asks you to fetch
|
|
233
|
+
posts, use the `fetch_posts` tool. Be concise in your responses.
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
2. Update your `gemini-extension.json` to load this file:
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"name": "my-first-extension",
|
|
241
|
+
"version": "1.0.0",
|
|
242
|
+
"contextFileName": "GEMINI.md",
|
|
243
|
+
"mcpServers": {
|
|
244
|
+
"nodeServer": {
|
|
245
|
+
"command": "node",
|
|
246
|
+
"args": ["${extensionPath}${/}example.js"],
|
|
247
|
+
"cwd": "${extensionPath}"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Restart Gemini CLI. The model now has the context from your `GEMINI.md` file in
|
|
254
|
+
every session where the extension is active.
|
|
255
|
+
|
|
256
|
+
## (Optional) Step 7: Add an Agent Skill
|
|
257
|
+
|
|
258
|
+
[Agent Skills](../cli/skills.md) bundle specialized expertise and workflows.
|
|
259
|
+
Skills are activated only when needed, which saves context tokens.
|
|
260
|
+
|
|
261
|
+
1. Create a `skills` directory and a subdirectory for your skill:
|
|
262
|
+
|
|
263
|
+
**macOS/Linux**
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
mkdir -p skills/security-audit
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Windows (PowerShell)**
|
|
270
|
+
|
|
271
|
+
```powershell
|
|
272
|
+
New-Item -ItemType Directory -Force -Path "skills\security-audit"
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
2. Create a `skills/security-audit/SKILL.md` file:
|
|
276
|
+
|
|
277
|
+
```markdown
|
|
278
|
+
---
|
|
279
|
+
name: security-audit
|
|
280
|
+
description:
|
|
281
|
+
Expertise in auditing code for security vulnerabilities. Use when the user
|
|
282
|
+
asks to "check for security issues" or "audit" their changes.
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
# Security Auditor
|
|
286
|
+
|
|
287
|
+
You are an expert security researcher. When auditing code:
|
|
288
|
+
|
|
289
|
+
1. Look for common vulnerabilities (OWASP Top 10).
|
|
290
|
+
2. Check for hardcoded secrets or API keys.
|
|
291
|
+
3. Suggest remediation steps for any findings.
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Gemini CLI automatically discovers skills bundled with your extension. The model
|
|
295
|
+
activates them when it identifies a relevant task.
|
|
296
|
+
|
|
297
|
+
## Step 8: Release your extension
|
|
298
|
+
|
|
299
|
+
When your extension is ready, share it with others via a Git repository or
|
|
300
|
+
GitHub Releases. Refer to the [Extension Releasing Guide](./releasing.md) for
|
|
301
|
+
detailed instructions and learn how to list your extension in the gallery.
|
|
302
|
+
|
|
303
|
+
## Next steps
|
|
304
|
+
|
|
305
|
+
- [Extension reference](reference.md): Deeply understand the extension format,
|
|
306
|
+
commands, and configuration.
|
|
307
|
+
- [Best practices](best-practices.md): Learn strategies for building great
|
|
308
|
+
extensions.
|