Skip to content

Commit 4dc8328

Browse files
committed
Codex testing
1 parent 623d6b3 commit 4dc8328

7 files changed

Lines changed: 205 additions & 65 deletions

File tree

.agents/plugins/marketplace.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "cloud-sql-postgresql-local",
3+
"interface": {
4+
"displayName": "Cloud SQL PostgreSQL Local"
5+
},
6+
"plugins": [
7+
{
8+
"name": "cloud-sql-postgresql",
9+
"source": {
10+
"source": "local",
11+
"path": "./plugins/cloud-sql-postgresql"
12+
},
13+
"policy": {
14+
"installation": "AVAILABLE",
15+
"authentication": "ON_INSTALL"
16+
},
17+
"category": "Database"
18+
}
19+
]
20+
}

.claude-plugin/marketplace.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.claude-plugin/plugin.json

Lines changed: 0 additions & 51 deletions
This file was deleted.

.codex-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"skills": "./skills/",
1919
"interface": {
20-
"displayName": "Cloud SQL for PostgreSQL Data",
20+
"displayName": "Cloud SQL for PostgreSQL Data 2",
2121
"shortDescription": "Explore PostgreSQL schemas, views, and stored procedures on Cloud SQL.",
2222
"longDescription": "Bundle the Cloud SQL for PostgreSQL data skills so Codex can inspect schema objects and execute SQL queries against the connected Cloud SQL instance.",
2323
"developerName": "Google Cloud SQL for PostgreSQL",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "cloud-sql-postgresql",
3+
"version": "0.1.0",
4+
"description": "Inspect Cloud SQL for PostgreSQL schema objects and run SQL with the data skills.",
5+
"author": {
6+
"name": "Google Cloud SQL for PostgreSQL",
7+
"email": "cloud-sql-postgresql@google.com",
8+
"url": "https://github.com/gemini-cli-extensions/cloud-sql-postgresql"
9+
},
10+
"homepage": "https://github.com/gemini-cli-extensions/cloud-sql-postgresql",
11+
"repository": "https://github.com/gemini-cli-extensions/cloud-sql-postgresql",
12+
"license": "Apache-2.0",
13+
"keywords": [
14+
"cloud-sql",
15+
"postgresql",
16+
"database"
17+
],
18+
"skills": "./skills/",
19+
"interface": {
20+
"displayName": "Cloud SQL for PostgreSQL Data 2",
21+
"shortDescription": "Explore PostgreSQL schemas, views, and stored procedures on Cloud SQL.",
22+
"longDescription": "Bundle the Cloud SQL for PostgreSQL data skills so Codex can inspect schema objects and execute SQL queries against the connected Cloud SQL instance.",
23+
"developerName": "Google Cloud SQL for PostgreSQL",
24+
"category": "Database",
25+
"capabilities": [
26+
"Read",
27+
"Write"
28+
],
29+
"websiteURL": "https://cloud.google.com/sql/docs/postgres",
30+
"privacyPolicyURL": "https://policies.google.com/privacy",
31+
"termsOfServiceURL": "https://policies.google.com/terms",
32+
"defaultPrompt": [
33+
"Use the Cloud SQL for PostgreSQL data skills to explore schema objects, views, and stored procedures.",
34+
"Run SQL queries against my Cloud SQL instance and summarize the results for me."
35+
]
36+
}
37+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: cloud-sql-postgres-data
3+
description: Use these skills when you need to explore the database structure, discover schema objects like views or stored procedures, and execute custom SQL queries to interact with your data.
4+
---
5+
6+
## Usage
7+
8+
All scripts can be executed using Node.js. Replace `<param_name>` and `<param_value>` with actual values.
9+
10+
**Bash:**
11+
`node <skill_dir>/scripts/<script_name>.js '{"<param_name>": "<param_value>"}'`
12+
13+
**PowerShell:**
14+
`node <skill_dir>/scripts/<script_name>.js '{\"<param_name>\": \"<param_value>\"}'`
15+
16+
Note: The scripts automatically load the environment variables from various .env files. Do not ask the user to set vars unless skill executions fails due to env var absence.
17+
18+
## Scripts
19+
20+
### execute_sql
21+
22+
Use this skill to execute sql.
23+
24+
#### Parameters
25+
26+
| Name | Type | Description | Required | Default |
27+
| :--- | :----- | :------------------ | :------- | :------ |
28+
| sql | string | The sql to execute. | Yes | |
29+
30+
---
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env node
2+
3+
// Copyright 2026 Google LLC
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
const { spawn } = require('child_process');
18+
const path = require('path');
19+
const fs = require('fs');
20+
const os = require('os');
21+
22+
/**
23+
* Configuration Constants
24+
*/
25+
const TOOL_NAME = "execute_sql";
26+
const CONFIG_ARGS = ["--prebuilt", "cloud-sql-postgres"];
27+
const OPTIONAL_VARS_TO_OMIT_IF_EMPTY = [
28+
'CLOUD_SQL_POSTGRES_USER',
29+
'CLOUD_SQL_POSTGRES_PASSWORD',
30+
'CLOUD_SQL_POSTGRES_IP_TYPE'
31+
];
32+
33+
/**
34+
* Merges external variables into the environment based on the current context.
35+
* For GEMINI_CLI, it loads from a .env file.
36+
* For CLAUDE_CODE, it transforms CLAUDE_PLUGIN_ prefixed variables.
37+
* @param {Object} env The environment object to populate.
38+
*/
39+
function mergeContextualVariables(env) {
40+
var env = {};
41+
42+
if (process.env.GEMINI_CLI === '1') {
43+
const envPath = path.resolve(__dirname, '../../../.env');
44+
if (fs.existsSync(envPath)) {
45+
fs.readFileSync(envPath, 'utf-8').split('\n').forEach(line => {
46+
const trimmed = line.trim();
47+
if (!trimmed || trimmed.startsWith('#')) return;
48+
const splitIdx = trimmed.indexOf('=');
49+
if (splitIdx === -1) return;
50+
const key = trimmed.slice(0, splitIdx).trim();
51+
const value = trimmed.slice(splitIdx + 1).trim().replace(/(^['"]|['"]$)/g, '');
52+
env[key] = value;
53+
});
54+
}
55+
} else if (process.env.CLAUDECODE === '1') {
56+
const prefix = 'CLAUDE_PLUGIN_OPTION_';
57+
for (const key in process.env) {
58+
if (key.startsWith(prefix)) {
59+
env[key.substring(prefix.length)] = process.env[key];
60+
}
61+
}
62+
}
63+
}
64+
65+
/**
66+
* Prepares the environment and determines the user agent.
67+
* @returns {{ env: Object, userAgent: string }}
68+
*/
69+
function prepareEnvironment() {
70+
var env = { ...process.env };
71+
let userAgent = "skills";
72+
73+
if (process.env.GEMINI_CLI === '1') {
74+
userAgent = "skills-geminicli";
75+
} else if (process.env.CLAUDECODE === '1') {
76+
userAgent = "skills-claudecode";
77+
}
78+
79+
mergeContextualVariables(env);
80+
81+
// Omit optional variables if they are empty strings to avoid misconfiguration
82+
OPTIONAL_VARS_TO_OMIT_IF_EMPTY.forEach(key => {
83+
if (env[key] === '') {
84+
delete env[key];
85+
}
86+
});
87+
88+
return { env, userAgent };
89+
}
90+
91+
/**
92+
* Main execution function.
93+
*/
94+
function main() {
95+
const { env, userAgent } = prepareEnvironment();
96+
const args = process.argv.slice(2);
97+
98+
const command = os.platform() === 'win32' ? 'npx.cmd' : 'npx';
99+
const processedArgs = os.platform() === 'win32' ? args.map(arg => arg.includes('"') ? '"' + arg.replace(/"/g, '""') + '"' : arg) : args;
100+
const npxArgs = ["--yes", "@toolbox-sdk/server@latest", "--log-level", "error", ...CONFIG_ARGS, "invoke", TOOL_NAME, "--user-agent-metadata", userAgent, ...processedArgs];
101+
102+
103+
const child = spawn(command, npxArgs, { shell: os.platform() === 'win32', stdio: 'inherit', env });
104+
105+
106+
child.on('close', (code) => {
107+
process.exit(code);
108+
});
109+
110+
child.on('error', (err) => {
111+
console.error("Error executing toolbox:", err);
112+
process.exit(1);
113+
});
114+
}
115+
116+
// Start the script
117+
main();

0 commit comments

Comments
 (0)