@orxataguy/tyr 1.6.4 → 1.6.5

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": "@orxataguy/tyr",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tyr": "./bin/tyr.js"
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import yaml from 'js-yaml';
4
+ import dotenv from 'dotenv';
4
5
  import { fileURLToPath, pathToFileURL } from 'url';
5
6
  import { homedir } from 'os';
6
7
  import { Container } from './Container';
@@ -52,6 +53,10 @@ export class Kernel {
52
53
 
53
54
  public async boot(args: string[]): Promise<void> {
54
55
  const isDebug = args.includes('--debug');
56
+
57
+ // Load all env vars from ~/.tyr/.env once, before anything else
58
+ (dotenv as any).config({ path: path.join(this.userRoot, '.env'), quiet: true });
59
+
55
60
  await this.container.init(isDebug);
56
61
 
57
62
  // All commands live in ~/.tyr/map.yml — the framework ships no runtime commands
@@ -1,7 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import axios from 'axios';
4
- import dotenv from 'dotenv';
5
4
  import type { TyrContext } from '../Kernel';
6
5
 
7
6
  type AIProvider = 'claude' | 'openai' | 'gemini';
@@ -124,7 +123,6 @@ export default function ai({ logger, fs: tyrFs, frameworkRoot, run, fail }: TyrC
124
123
  );
125
124
  }
126
125
 
127
- dotenv.config({ path: path.resolve(frameworkRoot, '.env'), override: true });
128
126
  const aiConfig = detectProvider();
129
127
  if (!aiConfig) {
130
128
  return fail(
@@ -21,6 +21,21 @@ function detectShellRcFile(homeDir: string): string | null {
21
21
 
22
22
  // ─── File templates ───────────────────────────────────────────────────────────
23
23
 
24
+ const ENV_TEMPLATE = `# ~/.tyr/.env
25
+ # Variables de entorno para Tyr. Este archivo nunca debe subirse a git.
26
+ #
27
+ # Base de datos SQL Server
28
+ MSSQL_USER=
29
+ MSSQL_PASSWORD=
30
+ MSSQL_SERVER=
31
+ MSSQL_DATABASE=
32
+ #
33
+ # Proveedores de IA (tyr ai)
34
+ CLAUDE_API_KEY=
35
+ OPENAI_API_KEY=
36
+ GEMINI_API_KEY=
37
+ `;
38
+
24
39
  const SH_ALIASES_TEMPLATE = `# ~/.tyr/aliases
25
40
  # Añade aquí tus aliases personalizados.
26
41
  # Este archivo se carga automáticamente por tu shell.
@@ -161,6 +176,13 @@ export default function config({ logger, fs: tyrFs, frameworkRoot, shell }: TyrC
161
176
  await tyrFs.write(mapPath, 'commands: {}\n');
162
177
  logger.success(`Archivo creado: ${mapPath}`);
163
178
 
179
+ // Write .env template
180
+ const envPath = path.join(userRoot, '.env');
181
+ if (!tyrFs.exists(envPath)) {
182
+ await tyrFs.write(envPath, ENV_TEMPLATE);
183
+ logger.success(`Archivo creado: ${envPath}`);
184
+ }
185
+
164
186
  // If linked to a repo, commit and push
165
187
  if (repoUrl) {
166
188
  logger.info('\nSubiendo configuración inicial al repositorio...');
@@ -1,11 +1,6 @@
1
- import dotenv from 'dotenv';
2
1
  import path from 'path';
3
- import { homedir } from 'os';
4
2
  import sql, { config as SQLConfig } from 'mssql';
5
3
 
6
- // Load credentials from ~/.tyr/.env — silently, optional
7
- (dotenv as any).config({ path: path.join(homedir(), '.tyr', '.env'), quiet: true });
8
-
9
4
  /**
10
5
  * @class SQLManager
11
6
  * @description Conector con la base de datos SQL Server.