Skip to content

Commit

Permalink
App working, cursor messing up big time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Acumen-Desktop committed Feb 10, 2025
1 parent 0f7f4c9 commit 4f0aadd
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 8 deletions.
32 changes: 32 additions & 0 deletions .cursor/rules/codebase.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description: Basic codebase instructions
globs:
---
# Codebase Rules

1. ALWAYS check existing files before creating new ones:

- Search in the codebase for similar functionality
- Check recently viewed files
- Use grep/semantic search to find related code

2. Framework & Architecture:

- This is an Electron app, NOT Tauri
- Use ESM modules with .mts extension
- Follow functional programming patterns
- Use the existing package manager (check package.json)

3. File Organization:

- Check ui-svelte/src-main/ for main process code
- Check ui-svelte/src-renderer/ for renderer process code
- Respect the existing file structure
- Don't duplicate functionality

4. Before Making Changes:
- Read the TypeScript organization guide
- Check for existing implementations
- Verify the tech stack being used
- Follow existing patterns in the codebase

8 changes: 0 additions & 8 deletions .cursor/rules/typescrip.mdc

This file was deleted.

30 changes: 30 additions & 0 deletions .cursor/rules/typescript.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
description: Read the Typescript instructions file
globs:
---

[types_instructions.md](mdc:acumen/types_instructions.md)

Read and update the typescript instructions file: 'acumen/types_instructions.md'.

# TypeScript Rules

1. Types MUST be in `.d.ts` files following the structure:

```
ui-svelte/
├── src-main/types/
│ ├── electron.d.ts # IPC & Window API
│ ├── ipc.d.ts # IPC Events & Payloads
│ └── config.d.ts # App & Env Config
├── src-renderer/
├── app.d.ts # Global & Window
└── types/ # Shared Types
```

2. NO type duplication across processes
3. Use `import type` statements
4. Component types stay with components
5. Prefer interfaces over type aliases
6. Use strict TypeScript config
7. Use barrel exports in index.d.ts files
73 changes: 73 additions & 0 deletions ui-svelte/src-main/lib/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Environment variable constants
export const GOOSE_PROVIDER = "GOOSE_PROVIDER";
export const GOOSE_MODEL = "GOOSE_MODEL";

// Provider API Keys
export const OPENAI_API_KEY = "OPENAI_API_KEY";
export const ANTHROPIC_API_KEY = "ANTHROPIC_API_KEY";
export const AZURE_API_KEY = "AZURE_API_KEY";
export const GOOGLE_API_KEY = "GOOGLE_API_KEY";
export const MISTRAL_API_KEY = "MISTRAL_API_KEY";

// Load environment variables from shell if in production
export async function loadShellEnv(
isProduction: boolean = false
): Promise<void> {
// Only proceed if running on macOS and in production mode
if (process.platform !== "darwin" || !isProduction) {
console.info(
`Skipping shell environment loading: ${
process.platform !== "darwin"
? "Not running on macOS"
: "Not in production mode"
}`
);
return;
}

try {
console.info("Loading environment variables from shell");
const { execSync } = await import("child_process");

const shell = process.env.SHELL || "/bin/bash";
const envStr = execSync(`${shell} -l -i -c 'env'`, {
encoding: "utf-8",
});

// Parse and set environment variables
envStr.split("\n").forEach((line) => {
const matches = line.match(/^([^=]+)=(.*)$/);
if (matches) {
const [, key, value] = matches;
console.info(`Setting ${key}`);
process.env[key] = value;
}
});

console.info("Successfully loaded shell environment variables");
} catch (error) {
console.error("Failed to load shell environment variables:", error);
}
}

// Get all provider API keys
export function getProviderKeys(): Record<string, string | undefined> {
return {
[OPENAI_API_KEY]: process.env[OPENAI_API_KEY],
[ANTHROPIC_API_KEY]: process.env[ANTHROPIC_API_KEY],
[AZURE_API_KEY]: process.env[AZURE_API_KEY],
[GOOGLE_API_KEY]: process.env[GOOGLE_API_KEY],
[MISTRAL_API_KEY]: process.env[MISTRAL_API_KEY],
};
}

// Update environment variables
export function updateEnvironmentVariables(
envToggles: Record<string, boolean>
): void {
Object.entries(envToggles).forEach(([key, enabled]) => {
if (!enabled && process.env[key]) {
delete process.env[key];
}
});
}
10 changes: 10 additions & 0 deletions ui-svelte/src-main/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ export interface AppConfigAPI {
setConfig: (settings: Settings) => Promise<void>;
getEnv: () => Promise<EnvToggles>;
}

// Provider types
export type Provider = "openai" | "anthropic" | "azure" | "google" | "mistral";

export interface ProviderConfig {
provider: Provider;
apiKey: string;
model?: string;
options?: Record<string, unknown>;
}

0 comments on commit 4f0aadd

Please sign in to comment.