Skip to content

Commit 00b3686

Browse files
blink-so[bot]ioAtif
andcommitted
Add Gemini CLI tasks template for matifali namespace
- Create new matifali namespace with Gemini CLI tasks template - Template includes Kubernetes deployment with Gemini CLI integration - Supports masked GEMINI_API_KEY parameter for secure API key input - Includes automated task execution and reporting capabilities - Based on existing Claude Code template structure - Includes comprehensive README and test files Co-authored-by: ioAtif <[email protected]>
1 parent 9e47369 commit 00b3686

File tree

3 files changed

+435
-0
lines changed

3 files changed

+435
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
display_name: Gemini CLI Tasks
3+
description: A Kubernetes workspace template with Gemini CLI for AI-powered coding tasks
4+
icon: ../../../../.icons/gemini.svg
5+
verified: false
6+
tags: [kubernetes, gemini, ai, google, tasks, node]
7+
---
8+
9+
# Gemini CLI Tasks Template
10+
11+
A complete Kubernetes workspace template that integrates Google's Gemini CLI for AI-powered coding assistance and automated task execution.
12+
13+
## Features
14+
15+
- **Kubernetes Deployment**: Full workspace running on Kubernetes with persistent storage
16+
- **Gemini CLI Integration**: Pre-configured with Google's Gemini AI models
17+
- **Task Automation**: Built-in support for automated task execution and reporting
18+
- **Node.js Environment**: Ready-to-use Node.js development environment
19+
- **Secure API Key Management**: Masked input for Gemini API key
20+
- **Interactive Terminal**: Direct terminal access for manual Gemini CLI usage
21+
22+
## Prerequisites
23+
24+
- Kubernetes cluster with Coder deployed
25+
- Gemini API key from Google AI Studio
26+
- Persistent volume support in your cluster
27+
28+
## Parameters
29+
30+
### GEMINI_API_KEY (Required)
31+
- **Type**: String (masked input)
32+
- **Description**: Your Gemini API key for accessing Google's AI models
33+
- **Sensitive**: Yes
34+
- **Mutable**: Yes
35+
36+
Get your API key from [Google AI Studio](https://aistudio.google.com/app/apikey).
37+
38+
### AI Prompt (Optional)
39+
- **Type**: String
40+
- **Description**: Task prompt for automated Gemini execution
41+
- **Mutable**: Yes
42+
- **Default**: Empty (interactive mode)
43+
44+
## Usage
45+
46+
### Interactive Mode
47+
48+
Leave the "AI Prompt" parameter empty to use Gemini CLI interactively:
49+
50+
1. Open the Terminal app in your workspace
51+
2. Run `gemini` to start an interactive session
52+
3. Ask questions or request coding assistance
53+
54+
### Automated Task Mode
55+
56+
Provide a task prompt to enable automated execution:
57+
58+
1. Set the "AI Prompt" parameter with your task description
59+
2. Gemini will automatically execute the task on workspace startup
60+
3. View task progress in the Coder UI
61+
62+
## Example Prompts
63+
64+
- "Create a simple Express.js API with user authentication"
65+
- "Set up a React application with TypeScript and Tailwind CSS"
66+
- "Write unit tests for the existing code in this repository"
67+
- "Refactor the code to follow best practices and add documentation"
68+
69+
## Security Considerations
70+
71+
- API keys are stored securely and masked in the UI
72+
- YOLO mode is disabled by default (requires manual approval for tool calls)
73+
- Workspace runs with non-root user (UID 1000)
74+
- Network policies can be applied to restrict external access
75+
76+
## Resources
77+
78+
- **CPU**: 250m requests, 2 cores limit
79+
- **Memory**: 512Mi requests, 4Gi limit
80+
- **Storage**: 10Gi persistent volume
81+
82+
## Troubleshooting
83+
84+
### Gemini CLI Not Found
85+
The template automatically installs Node.js and npm. If Gemini CLI is not available, check the startup logs in the agent.
86+
87+
### API Key Issues
88+
Ensure your Gemini API key is valid and has the necessary permissions. You can test it manually by running:
89+
```bash
90+
export GEMINI_API_KEY="your-key-here"
91+
gemini "Hello, can you help me?"
92+
```
93+
94+
### Task Reporting Not Working
95+
Make sure the Coder Login module is properly configured and the workspace has network access to the Coder server.
96+
97+
## Support
98+
99+
For issues with this template, please contact the template maintainer or file an issue in the Coder registry repository.
100+
101+
## Version History
102+
103+
- **1.0.0**: Initial release with basic Gemini CLI integration
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { describe, expect, it } from "bun:test";
2+
import { runTerraformInit, runTerraformPlan, TerraformPlan } from "../../test";
3+
4+
describe("gemini-cli", async () => {
5+
await runTerraformInit(import.meta.dir);
6+
7+
describe("plan", () => {
8+
it("default", async () => {
9+
const plan: TerraformPlan = await runTerraformPlan(import.meta.dir, {
10+
/// Parameters
11+
gemini_api_key: "test-api-key-12345",
12+
ai_prompt: "Create a simple Node.js application",
13+
});
14+
expect(plan.resource_changes).toHaveLength(4);
15+
expect(plan.resource_changes).toEqual(
16+
expect.arrayContaining([
17+
expect.objectContaining({
18+
type: "coder_agent",
19+
change: expect.objectContaining({
20+
actions: ["create"],
21+
}),
22+
}),
23+
expect.objectContaining({
24+
type: "kubernetes_deployment",
25+
change: expect.objectContaining({
26+
actions: ["create"],
27+
}),
28+
}),
29+
expect.objectContaining({
30+
type: "kubernetes_persistent_volume_claim",
31+
change: expect.objectContaining({
32+
actions: ["create"],
33+
}),
34+
}),
35+
expect.objectContaining({
36+
type: "coder_app",
37+
change: expect.objectContaining({
38+
actions: ["create"],
39+
}),
40+
}),
41+
])
42+
);
43+
});
44+
45+
it("validates gemini api key parameter", async () => {
46+
const plan: TerraformPlan = await runTerraformPlan(import.meta.dir, {
47+
gemini_api_key: "sk-test-key",
48+
ai_prompt: "",
49+
});
50+
51+
// Check that the agent has the correct environment variables
52+
const agent = plan.resource_changes.find(
53+
(resource) => resource.type === "coder_agent"
54+
);
55+
expect(agent?.change?.after?.env).toMatchObject({
56+
GEMINI_API_KEY: "sk-test-key",
57+
CODER_MCP_GEMINI_API_KEY: "sk-test-key",
58+
});
59+
});
60+
61+
it("validates ai prompt parameter", async () => {
62+
const plan: TerraformPlan = await runTerraformPlan(import.meta.dir, {
63+
gemini_api_key: "test-key",
64+
ai_prompt: "Write a Python script",
65+
});
66+
67+
// Check that the agent has the correct task prompt
68+
const agent = plan.resource_changes.find(
69+
(resource) => resource.type === "coder_agent"
70+
);
71+
expect(agent?.change?.after?.env?.CODER_MCP_GEMINI_TASK_PROMPT).toBe(
72+
"Write a Python script"
73+
);
74+
});
75+
76+
it("creates kubernetes resources with correct labels", async () => {
77+
const plan: TerraformPlan = await runTerraformPlan(import.meta.dir, {
78+
gemini_api_key: "test-key",
79+
ai_prompt: "",
80+
});
81+
82+
// Check deployment labels
83+
const deployment = plan.resource_changes.find(
84+
(resource) => resource.type === "kubernetes_deployment"
85+
);
86+
expect(deployment?.change?.after?.metadata?.[0]?.labels).toMatchObject({
87+
"app.kubernetes.io/name": "coder-workspace",
88+
"app.kubernetes.io/part-of": "coder",
89+
"com.coder.resource": "true",
90+
});
91+
92+
// Check PVC labels
93+
const pvc = plan.resource_changes.find(
94+
(resource) => resource.type === "kubernetes_persistent_volume_claim"
95+
);
96+
expect(pvc?.change?.after?.metadata?.[0]?.labels).toMatchObject({
97+
"app.kubernetes.io/name": "coder-pvc",
98+
"app.kubernetes.io/part-of": "coder",
99+
"com.coder.resource": "true",
100+
});
101+
});
102+
103+
it("configures container with correct image and resources", async () => {
104+
const plan: TerraformPlan = await runTerraformPlan(import.meta.dir, {
105+
gemini_api_key: "test-key",
106+
ai_prompt: "",
107+
});
108+
109+
const deployment = plan.resource_changes.find(
110+
(resource) => resource.type === "kubernetes_deployment"
111+
);
112+
const container = deployment?.change?.after?.spec?.[0]?.template?.[0]?.spec?.[0]?.container?.[0];
113+
114+
expect(container?.image).toBe("codercom/enterprise-node:ubuntu");
115+
expect(container?.resources?.[0]?.requests).toMatchObject({
116+
cpu: "250m",
117+
memory: "512Mi",
118+
});
119+
expect(container?.resources?.[0]?.limits).toMatchObject({
120+
cpu: "2",
121+
memory: "4Gi",
122+
});
123+
});
124+
});
125+
});

0 commit comments

Comments
 (0)