feat: implement Gemini CLI extension support
This commit is contained in:
parent
b633ae81f6
commit
44b3722a79
13 changed files with 1342 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1,3 @@
|
|||
.idea/
|
||||
node_modules/
|
||||
dist/
|
||||
|
|
|
|||
11
GEMINI.md
Normal file
11
GEMINI.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Host UK Core Agent
|
||||
|
||||
This extension provides tools and workflows for the Host UK development environment.
|
||||
It helps with code review, verification, QA, and CI tasks.
|
||||
|
||||
## Key Features
|
||||
|
||||
- **Core CLI Integration**: Enforces the use of `core` CLI (`host-uk/core` wrapper for go/php tools) to ensure consistency.
|
||||
- **Auto-formatting**: Automatically formats Go and PHP code on edit.
|
||||
- **Safety Checks**: Blocks destructive commands like `rm -rf` to prevent accidents.
|
||||
- **Skills**: Provides data collection skills for various crypto/blockchain domains (e.g., Ledger papers, BitcoinTalk archives).
|
||||
4
commands/code/remember.toml
Normal file
4
commands/code/remember.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
prompt = """
|
||||
Remembering fact: {{args}}
|
||||
!{${extensionPath}/claude/code/scripts/capture-context.sh "{{args}}" "user"}
|
||||
"""
|
||||
21
commands/code/yes.toml
Normal file
21
commands/code/yes.toml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
prompt = """
|
||||
You are in **auto-approve mode**. The user trusts you to complete this task autonomously.
|
||||
|
||||
## Task
|
||||
{{args}}
|
||||
|
||||
## Rules
|
||||
1. **Complete the full workflow** - don't stop until done
|
||||
2. **Commit when finished** - create a commit with the changes
|
||||
3. **Use conventional commits** - type(scope): description
|
||||
|
||||
## Workflow
|
||||
1. Understand the task
|
||||
2. Make necessary changes
|
||||
3. Run tests to verify (`core go test` or `core php test`)
|
||||
4. Format code (`core go fmt` or `core php fmt`)
|
||||
5. Commit changes
|
||||
6. Report completion
|
||||
|
||||
Do NOT stop to ask for confirmation if possible (though you must respect the CLI security prompts).
|
||||
"""
|
||||
8
commands/qa/fix.toml
Normal file
8
commands/qa/fix.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
prompt = """
|
||||
Fix the following QA issue:
|
||||
{{args}}
|
||||
|
||||
1. Analyze the issue.
|
||||
2. Apply the fix.
|
||||
3. Verify the fix with `core go test` or `core php test`.
|
||||
"""
|
||||
10
commands/qa/qa.toml
Normal file
10
commands/qa/qa.toml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
prompt = """
|
||||
Run the QA loop for the current project.
|
||||
|
||||
1. **Detect Project Type**: Check if this is a Go or PHP project.
|
||||
2. **Run QA**:
|
||||
- Go: `core go qa`
|
||||
- PHP: `core php qa`
|
||||
3. **Fix Issues**: If errors are found, fix them and re-run QA.
|
||||
4. **Repeat**: Continue until all checks pass.
|
||||
"""
|
||||
15
gemini-extension.json
Normal file
15
gemini-extension.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "host-uk-core-agent",
|
||||
"version": "0.1.0",
|
||||
"description": "Host UK Core Agent Extension for Gemini CLI",
|
||||
"contextFileName": "GEMINI.md",
|
||||
"mcpServers": {
|
||||
"core-agent": {
|
||||
"command": "node",
|
||||
"args": [
|
||||
"${extensionPath}/src/index.js"
|
||||
],
|
||||
"cwd": "${extensionPath}"
|
||||
}
|
||||
}
|
||||
}
|
||||
58
hooks/hooks.json
Normal file
58
hooks/hooks.json
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"hooks": {
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "run_shell_command",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${extensionPath}/claude/code/hooks/prefer-core.sh"
|
||||
}
|
||||
],
|
||||
"description": "Block destructive commands (rm -rf, sed -i, xargs rm) and enforce core CLI"
|
||||
},
|
||||
{
|
||||
"matcher": "write_to_file",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${extensionPath}/claude/code/scripts/block-docs.sh"
|
||||
}
|
||||
],
|
||||
"description": "Block random .md file creation"
|
||||
}
|
||||
],
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "replace_file_content && tool_input.TargetFile matches \"\\.go$\"",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${extensionPath}/claude/code/scripts/go-format.sh"
|
||||
}
|
||||
],
|
||||
"description": "Auto-format Go files after edits"
|
||||
},
|
||||
{
|
||||
"matcher": "replace_file_content && tool_input.TargetFile matches \"\\.php$\"",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${extensionPath}/claude/code/scripts/php-format.sh"
|
||||
}
|
||||
],
|
||||
"description": "Auto-format PHP files after edits"
|
||||
},
|
||||
{
|
||||
"matcher": "replace_file_content",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${extensionPath}/claude/code/scripts/check-debug.sh"
|
||||
}
|
||||
],
|
||||
"description": "Warn about debug statements (dd, dump, fmt.Println)"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
1162
package-lock.json
generated
Normal file
1162
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
18
package.json
Normal file
18
package.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "host-uk-core-agent",
|
||||
"version": "0.1.0",
|
||||
"description": "Host UK Core Agent Extension for Gemini CLI",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.0.1",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.4",
|
||||
"@types/node": "^22.5.0"
|
||||
}
|
||||
}
|
||||
1
skills
Symbolic link
1
skills
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
claude/code/skills
|
||||
16
src/index.ts
Normal file
16
src/index.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env node
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
||||
import { z } from 'zod';
|
||||
|
||||
const server = new McpServer({
|
||||
name: 'host-uk-core-agent',
|
||||
version: '0.1.0',
|
||||
});
|
||||
|
||||
// Example tool - can be expanded to wrap the bash scripts if we want them as tools
|
||||
// For now, most logic is in the bash scripts invoked by hooks or commands.
|
||||
// We keep this minimal to satisfy the gemini-extension.json requirement.
|
||||
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "Node16",
|
||||
"moduleResolution": "Node16",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue