Skip to content

Commit 288fcca

Browse files
committed
regenerate skills with new logic
1 parent 2b0cea4 commit 288fcca

30 files changed

Lines changed: 1586 additions & 832 deletions

skills/cloudsql-postgres/SKILL.md

Lines changed: 119 additions & 427 deletions
Large diffs are not rendered by default.

skills/cloudsql-postgres/scripts/database_overview.js

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
#!/usr/bin/env node
2-
require('./load_env.js');
2+
3+
// Copyright 2025 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.
316

417
const { spawn, execSync } = require('child_process');
518
const path = require('path');
619
const fs = require('fs');
720

8-
921
const toolName = "database_overview";
10-
const toolsFileName = "database_overview.yaml";
22+
const configArgs = ["--prebuilt", "cloud-sql-postgres"];
1123

1224
function getToolboxPath() {
25+
if (process.env.GEMINI_CLI === '1') {
26+
const localPath = path.resolve(__dirname, '../../../toolbox');
27+
if (fs.existsSync(localPath)) {
28+
return localPath;
29+
}
30+
}
1331
try {
1432
const checkCommand = process.platform === 'win32' ? 'where toolbox' : 'which toolbox';
1533
const globalPath = execSync(checkCommand, { stdio: 'pipe', encoding: 'utf-8' }).trim();
1634
if (globalPath) {
1735
return globalPath.split('\n')[0].trim();
1836
}
37+
throw new Error("Toolbox binary not found");
1938
} catch (e) {
20-
// Ignore error;
39+
throw new Error("Toolbox binary not found");
2140
}
22-
const localPath = path.resolve(__dirname, '../../../toolbox');
23-
if (fs.existsSync(localPath)) {
24-
return localPath;
25-
}
26-
throw new Error("Toolbox binary not found");
2741
}
2842

2943
let toolboxBinary;
@@ -34,15 +48,38 @@ try {
3448
process.exit(1);
3549
}
3650

37-
let configArgs = [];
38-
if (toolsFileName) {
39-
configArgs.push("--tools-file", path.join(__dirname, "..", "assets", toolsFileName));
51+
function getEnv() {
52+
const envPath = path.resolve(__dirname, '../../../.env');
53+
const env = { ...process.env };
54+
if (fs.existsSync(envPath)) {
55+
const envContent = fs.readFileSync(envPath, 'utf-8');
56+
envContent.split('\n').forEach(line => {
57+
const trimmed = line.trim();
58+
if (trimmed && !trimmed.startsWith('#')) {
59+
const splitIdx = trimmed.indexOf('=');
60+
if (splitIdx !== -1) {
61+
const key = trimmed.slice(0, splitIdx).trim();
62+
let value = trimmed.slice(splitIdx + 1).trim();
63+
value = value.replace(/(^['"]|['"]$)/g, '');
64+
if (env[key] === undefined) {
65+
env[key] = value;
66+
}
67+
}
68+
}
69+
});
70+
}
71+
return env;
72+
}
73+
74+
let env = process.env;
75+
if (process.env.GEMINI_CLI === '1') {
76+
env = getEnv();
4077
}
4178

4279
const args = process.argv.slice(2);
43-
const toolboxArgs = [...configArgs, "invoke", toolName, ...args];
80+
const toolboxArgs = ["--log-level", "error", ...configArgs, "invoke", toolName, ...args];
4481

45-
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit' });
82+
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit', env });
4683

4784
child.on('close', (code) => {
4885
process.exit(code);

skills/cloudsql-postgres/scripts/execute_sql.js

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
#!/usr/bin/env node
2-
require('./load_env.js');
2+
3+
// Copyright 2025 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.
316

417
const { spawn, execSync } = require('child_process');
518
const path = require('path');
619
const fs = require('fs');
720

821
const toolName = "execute_sql";
9-
const toolsFileName = "execute_sql.yaml";
22+
const configArgs = ["--prebuilt", "cloud-sql-postgres"];
1023

1124
function getToolboxPath() {
25+
if (process.env.GEMINI_CLI === '1') {
26+
const localPath = path.resolve(__dirname, '../../../toolbox');
27+
if (fs.existsSync(localPath)) {
28+
return localPath;
29+
}
30+
}
1231
try {
1332
const checkCommand = process.platform === 'win32' ? 'where toolbox' : 'which toolbox';
1433
const globalPath = execSync(checkCommand, { stdio: 'pipe', encoding: 'utf-8' }).trim();
1534
if (globalPath) {
1635
return globalPath.split('\n')[0].trim();
1736
}
37+
throw new Error("Toolbox binary not found");
1838
} catch (e) {
19-
// Ignore error;
20-
}
21-
const localPath = path.resolve(__dirname, '../../../toolbox');
22-
if (fs.existsSync(localPath)) {
23-
return localPath;
39+
throw new Error("Toolbox binary not found");
2440
}
25-
throw new Error("Toolbox binary not found");
2641
}
2742

2843
let toolboxBinary;
@@ -33,15 +48,38 @@ try {
3348
process.exit(1);
3449
}
3550

36-
let configArgs = [];
37-
if (toolsFileName) {
38-
configArgs.push("--tools-file", path.join(__dirname, "..", "assets", toolsFileName));
51+
function getEnv() {
52+
const envPath = path.resolve(__dirname, '../../../.env');
53+
const env = { ...process.env };
54+
if (fs.existsSync(envPath)) {
55+
const envContent = fs.readFileSync(envPath, 'utf-8');
56+
envContent.split('\n').forEach(line => {
57+
const trimmed = line.trim();
58+
if (trimmed && !trimmed.startsWith('#')) {
59+
const splitIdx = trimmed.indexOf('=');
60+
if (splitIdx !== -1) {
61+
const key = trimmed.slice(0, splitIdx).trim();
62+
let value = trimmed.slice(splitIdx + 1).trim();
63+
value = value.replace(/(^['"]|['"]$)/g, '');
64+
if (env[key] === undefined) {
65+
env[key] = value;
66+
}
67+
}
68+
}
69+
});
70+
}
71+
return env;
72+
}
73+
74+
let env = process.env;
75+
if (process.env.GEMINI_CLI === '1') {
76+
env = getEnv();
3977
}
4078

4179
const args = process.argv.slice(2);
42-
const toolboxArgs = [...configArgs, "invoke", toolName, ...args];
80+
const toolboxArgs = ["--log-level", "error", ...configArgs, "invoke", toolName, ...args];
4381

44-
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit' });
82+
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit', env });
4583

4684
child.on('close', (code) => {
4785
process.exit(code);

skills/cloudsql-postgres/scripts/get_column_cardinality.js

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
#!/usr/bin/env node
2-
require('./load_env.js');
2+
3+
// Copyright 2025 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.
316

417
const { spawn, execSync } = require('child_process');
518
const path = require('path');
619
const fs = require('fs');
720

8-
921
const toolName = "get_column_cardinality";
10-
const toolsFileName = "get_column_cardinality.yaml";
22+
const configArgs = ["--prebuilt", "cloud-sql-postgres"];
1123

1224
function getToolboxPath() {
25+
if (process.env.GEMINI_CLI === '1') {
26+
const localPath = path.resolve(__dirname, '../../../toolbox');
27+
if (fs.existsSync(localPath)) {
28+
return localPath;
29+
}
30+
}
1331
try {
1432
const checkCommand = process.platform === 'win32' ? 'where toolbox' : 'which toolbox';
1533
const globalPath = execSync(checkCommand, { stdio: 'pipe', encoding: 'utf-8' }).trim();
1634
if (globalPath) {
1735
return globalPath.split('\n')[0].trim();
1836
}
37+
throw new Error("Toolbox binary not found");
1938
} catch (e) {
20-
// Ignore error;
39+
throw new Error("Toolbox binary not found");
2140
}
22-
const localPath = path.resolve(__dirname, '../../../toolbox');
23-
if (fs.existsSync(localPath)) {
24-
return localPath;
25-
}
26-
throw new Error("Toolbox binary not found");
2741
}
2842

2943
let toolboxBinary;
@@ -34,15 +48,38 @@ try {
3448
process.exit(1);
3549
}
3650

37-
let configArgs = [];
38-
if (toolsFileName) {
39-
configArgs.push("--tools-file", path.join(__dirname, "..", "assets", toolsFileName));
51+
function getEnv() {
52+
const envPath = path.resolve(__dirname, '../../../.env');
53+
const env = { ...process.env };
54+
if (fs.existsSync(envPath)) {
55+
const envContent = fs.readFileSync(envPath, 'utf-8');
56+
envContent.split('\n').forEach(line => {
57+
const trimmed = line.trim();
58+
if (trimmed && !trimmed.startsWith('#')) {
59+
const splitIdx = trimmed.indexOf('=');
60+
if (splitIdx !== -1) {
61+
const key = trimmed.slice(0, splitIdx).trim();
62+
let value = trimmed.slice(splitIdx + 1).trim();
63+
value = value.replace(/(^['"]|['"]$)/g, '');
64+
if (env[key] === undefined) {
65+
env[key] = value;
66+
}
67+
}
68+
}
69+
});
70+
}
71+
return env;
72+
}
73+
74+
let env = process.env;
75+
if (process.env.GEMINI_CLI === '1') {
76+
env = getEnv();
4077
}
4178

4279
const args = process.argv.slice(2);
43-
const toolboxArgs = [...configArgs, "invoke", toolName, ...args];
80+
const toolboxArgs = ["--log-level", "error", ...configArgs, "invoke", toolName, ...args];
4481

45-
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit' });
82+
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit', env });
4683

4784
child.on('close', (code) => {
4885
process.exit(code);

skills/cloudsql-postgres/scripts/get_query_plan.js

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
#!/usr/bin/env node
2-
require('./load_env.js');
2+
3+
// Copyright 2025 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.
316

417
const { spawn, execSync } = require('child_process');
518
const path = require('path');
619
const fs = require('fs');
720

8-
921
const toolName = "get_query_plan";
10-
const toolsFileName = "get_query_plan.yaml";
22+
const configArgs = ["--prebuilt", "cloud-sql-postgres"];
1123

1224
function getToolboxPath() {
25+
if (process.env.GEMINI_CLI === '1') {
26+
const localPath = path.resolve(__dirname, '../../../toolbox');
27+
if (fs.existsSync(localPath)) {
28+
return localPath;
29+
}
30+
}
1331
try {
1432
const checkCommand = process.platform === 'win32' ? 'where toolbox' : 'which toolbox';
1533
const globalPath = execSync(checkCommand, { stdio: 'pipe', encoding: 'utf-8' }).trim();
1634
if (globalPath) {
1735
return globalPath.split('\n')[0].trim();
1836
}
37+
throw new Error("Toolbox binary not found");
1938
} catch (e) {
20-
// Ignore error;
39+
throw new Error("Toolbox binary not found");
2140
}
22-
const localPath = path.resolve(__dirname, '../../../toolbox');
23-
if (fs.existsSync(localPath)) {
24-
return localPath;
25-
}
26-
throw new Error("Toolbox binary not found");
2741
}
2842

2943
let toolboxBinary;
@@ -34,15 +48,38 @@ try {
3448
process.exit(1);
3549
}
3650

37-
let configArgs = [];
38-
if (toolsFileName) {
39-
configArgs.push("--tools-file", path.join(__dirname, "..", "assets", toolsFileName));
51+
function getEnv() {
52+
const envPath = path.resolve(__dirname, '../../../.env');
53+
const env = { ...process.env };
54+
if (fs.existsSync(envPath)) {
55+
const envContent = fs.readFileSync(envPath, 'utf-8');
56+
envContent.split('\n').forEach(line => {
57+
const trimmed = line.trim();
58+
if (trimmed && !trimmed.startsWith('#')) {
59+
const splitIdx = trimmed.indexOf('=');
60+
if (splitIdx !== -1) {
61+
const key = trimmed.slice(0, splitIdx).trim();
62+
let value = trimmed.slice(splitIdx + 1).trim();
63+
value = value.replace(/(^['"]|['"]$)/g, '');
64+
if (env[key] === undefined) {
65+
env[key] = value;
66+
}
67+
}
68+
}
69+
});
70+
}
71+
return env;
72+
}
73+
74+
let env = process.env;
75+
if (process.env.GEMINI_CLI === '1') {
76+
env = getEnv();
4077
}
4178

4279
const args = process.argv.slice(2);
43-
const toolboxArgs = [...configArgs, "invoke", toolName, ...args];
80+
const toolboxArgs = ["--log-level", "error", ...configArgs, "invoke", toolName, ...args];
4481

45-
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit' });
82+
const child = spawn(toolboxBinary, toolboxArgs, { stdio: 'inherit', env });
4683

4784
child.on('close', (code) => {
4885
process.exit(code);

0 commit comments

Comments
 (0)