@blogic-cz/agent-tools 0.4.0 → 0.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogic-cz/agent-tools",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure DevOps, logs, and sessions",
5
5
  "keywords": [
6
6
  "agent",
@@ -17,6 +17,21 @@ import { detectSchemaError, isValidTableName, isMutationQuery } from "./security
17
17
 
18
18
  const LOCALHOST_HOSTS = new Set(["localhost", "127.0.0.1"]);
19
19
 
20
+ export function resolveDbAccessMode(
21
+ env: string,
22
+ host: string,
23
+ hasKubectlConfig: boolean,
24
+ ): Pick<DbConfig, "allowMutations" | "host" | "needsTunnel"> {
25
+ const isLocalHost = LOCALHOST_HOSTS.has(host);
26
+ const isLocalEnvironment = env === "local";
27
+
28
+ return {
29
+ host,
30
+ needsTunnel: hasKubectlConfig && !isLocalEnvironment && isLocalHost,
31
+ allowMutations: isLocalEnvironment,
32
+ };
33
+ }
34
+
20
35
  export class DbService extends ServiceMap.Service<
21
36
  DbService,
22
37
  {
@@ -79,10 +94,11 @@ export class DbService extends ServiceMap.Service<
79
94
 
80
95
  const envVars: Record<string, string> = {};
81
96
  const regex = /^export\s+([A-Z_][A-Z0-9_]*)=["']?([^"'\n]+)["']?/gm;
82
- let match: RegExpExecArray | null;
97
+ let match = regex.exec(content);
83
98
 
84
- while ((match = regex.exec(content)) !== null) {
99
+ while (match !== null) {
85
100
  envVars[match[1]] = match[2];
101
+ match = regex.exec(content);
86
102
  }
87
103
 
88
104
  yield* Ref.set(zshrcEnvCache, envVars);
@@ -214,7 +230,7 @@ export class DbService extends ServiceMap.Service<
214
230
  ) => {
215
231
  const args = [
216
232
  "-h",
217
- "localhost",
233
+ config.host,
218
234
  "-p",
219
235
  String(config.port),
220
236
  "-U",
@@ -505,15 +521,21 @@ export class DbService extends ServiceMap.Service<
505
521
  throw new Error(`Unknown environment "${env}". Available: ${available}`);
506
522
  }
507
523
 
508
- const isLocal = LOCALHOST_HOSTS.has(envConfig.host);
524
+ const accessMode = resolveDbAccessMode(
525
+ env,
526
+ envConfig.host,
527
+ dbConfig.kubectl !== undefined,
528
+ );
509
529
 
510
530
  return {
531
+ host: accessMode.host,
511
532
  user: envConfig.user,
512
533
  database: envConfig.database,
534
+ password: envConfig.password,
513
535
  passwordEnvVar: envConfig.passwordEnvVar,
514
536
  port: envConfig.port,
515
- needsTunnel: !isLocal && dbConfig.kubectl !== undefined,
516
- allowMutations: isLocal,
537
+ needsTunnel: accessMode.needsTunnel,
538
+ allowMutations: accessMode.allowMutations,
517
539
  };
518
540
  };
519
541
 
@@ -4,6 +4,7 @@ export type { Environment, OutputFormat };
4
4
  export type SchemaMode = "tables" | "columns" | "full" | "relationships";
5
5
 
6
6
  export type DbConfig = {
7
+ host: string;
7
8
  user: string;
8
9
  database: string;
9
10
  password?: string;