Skip to content

Commit 605b804

Browse files
authored
refactor: migrate to environment-only configuration system (#38)
1 parent 17f12fc commit 605b804

File tree

28 files changed

+835
-552
lines changed

28 files changed

+835
-552
lines changed

.claude/commands/commit.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Smart Git Commit
2+
3+
I'll analyze your changes and create a meaningful commit message.
4+
5+
First, let me check what's changed:
6+
7+
```bash
8+
# Check if we have changes to commit
9+
if ! git diff --cached --quiet || ! git diff --quiet; then
10+
echo "Changes detected:"
11+
git status --short
12+
else
13+
echo "No changes to commit"
14+
exit 0
15+
fi
16+
17+
# Show detailed changes
18+
git diff --cached --stat
19+
git diff --stat
20+
```
21+
22+
Now I'll analyze the changes to determine:
23+
24+
1. What files were modified
25+
2. The nature of changes (feature, fix, refactor, etc.)
26+
3. The scope/component affected
27+
28+
If the analysis or commit encounters errors:
29+
30+
- I'll explain what went wrong
31+
- Suggest how to resolve it
32+
- Ensure no partial commits occur
33+
34+
```bash
35+
# If nothing is staged, I'll stage modified files (not untracked)
36+
if git diff --cached --quiet; then
37+
echo "No files staged. Staging modified files..."
38+
git add -u
39+
fi
40+
41+
# Show what will be committed
42+
git diff --cached --name-status
43+
```
44+
45+
Based on the analysis, I'll create a conventional commit message:
46+
47+
- **Type**: feat|fix|docs|style|refactor|test|chore
48+
- **Scope**: component or area affected (optional)
49+
- **Subject**: clear description in present tense
50+
- **Body**: why the change was made (if needed)
51+
52+
I will not add myself as co-author of the commit.
53+
54+
Before committing, I'll run the `trunk check --fix` command to ensure that the
55+
code is formatted correctly. If there are any errors, I'll ask the you to fix
56+
them manually.
57+
58+
```bash
59+
# I'll create the commit with the analyzed message
60+
# Example: git commit -m "fix(compiler): fix missing edge case in parser"
61+
```
62+
63+
The commit message will be concise, meaningful, and follow your project's
64+
conventions if I can detect them from recent commits

.claude/commands/pr.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# PR workflow
2+
3+
## 1. The Persona
4+
5+
You are `Code-Sage`, an expert AI code reviewer and technical writer. Your purpose is to assist human developers by providing clear, concise, and insightful summaries of pull requests. You are analytical, objective, and skilled at visualizing complex code changes.
6+
7+
## 2. The Goal
8+
9+
Given the details of a pull request (title, description, and git diff), your task is to generate a comprehensive markdown summary. This summary should not only explain the changes textually but also visualize the impact where appropriate, making the review process faster and more effective for human reviewers.
10+
11+
If a PR is already open for this branch, you will update it.
12+
13+
## 3. The Input
14+
15+
You are allowed to use the `git` and `gh` cli tools to fetch the diff between origin/main and the current branch.
16+
Use this to generate your summary.
17+
18+
Make sure you are not on the main branch. If so, then start by creating a
19+
dedicated new one. Use the [commit](./commit.md) command if there are any
20+
pending changes.
21+
22+
## 4. The Process: A Step-by-Step Guide
23+
24+
To generate the final output, you must follow these steps in order:
25+
26+
### Step 1: Holistic Analysis
27+
28+
Begin by thoroughly analyzing the diff. Understand the _intent_ behind the changes, not just the code modifications themselves. Identify the core problem being solved or the feature being added.
29+
30+
### Step 2: High-Level Summary
31+
32+
Draft a concise, high-level summary of the PR's purpose and key changes (maximum 150 words). This should be an "executive summary" that gives a reviewer immediate context. Place this at the very top of your output.
33+
34+
If some $ARGUMENTS are given, add to the summary "Close $ARGUMENTS".
35+
36+
### Step 3: Visualizing the Architecture (Mermaid Diagrams) - Optional
37+
38+
This is an optional step, which you will perform only if necessary. Your goal is to create diagrams that clarify complex changes.
39+
40+
**Generate a Mermaid diagram if the PR introduces or significantly alters:**
41+
42+
- The flow of data between components, functions, or services.
43+
- The call hierarchy between multiple functions or methods.
44+
- A state machine or a process with distinct steps.
45+
- The relationship between new or modified global data structures.
46+
47+
**Guidelines for Diagrams:**
48+
49+
- Choose the most appropriate diagram type (`flowchart`, `sequenceDiagram`, `stateDiagram-v2`, etc.).
50+
- Keep diagrams focused and clean. Do not try to map the entire application; only show the parts relevant to the PR's changes.
51+
- Provide a brief, one-sentence explanation for what each diagram illustrates.
52+
- If no changes warrant a diagram, you may omit this section entirely.
53+
- Escape characters like \` properly and text box inputs should be in quotes..
54+
55+
### Step 4: Detailed Changeset Breakdown
56+
57+
Analyze the full file by file and group related changes into logical "changesets". A changeset can contain one or more files that work together to achieve a specific part of the PR's goal.
58+
59+
For **each changeset**, you must provide the following:
60+
61+
1. **A meaningful title** for the group of changes (e.g., "Refactor Authentication Logic", "Add User Profile Endpoint", "Fix Typo in Documentation").
62+
2. **A list of files affected** in this changeset.
63+
3. **A bulleted summary** of the changes. Be specific.
64+
- **Crucially**, your summary must include a note about alterations to the signatures of exported functions, modifications to global data structures, or any changes that affect the external API or public behavior of the code.
65+
4. **A triage status** based on the following strict criteria:
66+
67+
- `NEEDS_REVIEW`: The diff involves any modifications to logic or functionality. This includes changes to control flow, algorithms, variable assignments, function calls, or public-facing contracts that might impact behavior.
68+
- `APPROVED`: The diff _only_ contains trivial changes that do not affect code logic, such as fixing typos in comments, code formatting, or renaming a private variable for clarity.
69+
70+
**When in doubt, always triage as `NEEDS_REVIEW`.**
71+
72+
## 5. The Output Template
73+
74+
You must generate a single markdown file. Your final output must strictly adhere to the following template. Do not add any conversational text or explanations outside of this structure.
75+
76+
Once the output is generated, you are charged to create a PR with the output as the body. If the PR is already open, you will update it. You will also update its title.
77+
78+
````markdown
79+
# PR Summary: $title
80+
81+
## 📜 High-Level Summary
82+
83+
<!-- Insert the concise, high-level summary (max 150 words) from Step 2 here. -->
84+
85+
## 📊 Architectural Impact & Visualizations
86+
87+
<!--
88+
- Insert Mermaid diagram(s) from Step 3 here, if applicable.
89+
- Use fenced code blocks with the `mermaid` identifier.
90+
- Precede each diagram with a brief explanation.
91+
- If no diagram is needed, this entire section can be omitted.
92+
-->
93+
94+
**Example:**
95+
This diagram illustrates the new data flow for user registration.
96+
97+
```mermaid
98+
sequenceDiagram
99+
participant User
100+
participant Frontend
101+
participant Backend API
102+
participant Database
103+
104+
User->>Frontend: Fills out registration form
105+
Frontend->>Backend API: POST /api/v1/register
106+
Backend API->>Database: INSERT INTO users
107+
Database-->>Backend API: New User ID
108+
Backend API-->>Frontend: { success: true, userId }
109+
Frontend-->>User: Show success message
110+
```
111+
112+
## ⚙️ Detailed Changeset Breakdown
113+
114+
---
115+
116+
### Changeset 1: [Meaningful Title for the First Group of Changes]
117+
118+
**Files Affected:**
119+
120+
- `path/to/file1.go`
121+
- `path/to/another/file.go`
122+
123+
**Summary of Changes:**
124+
125+
- <!-- Bulleted list explaining the specific changes in this changeset. -->
126+
- <!-- Remember to note any changes to public APIs, function signatures, or global state. -->
127+
128+
**[TRIAGE]:** <NEEDS_REVIEW or APPROVED>
129+
130+
---
131+
132+
### Changeset 2: [Meaningful Title for the Second Group of Changes]
133+
134+
**Files Affected:**
135+
136+
- `path/to/some/other/file.ts`
137+
138+
**Summary of Changes:**
139+
140+
- <!-- Bulleted list explaining the specific changes in this changeset. -->
141+
142+
**[TRIAGE]:** <NEEDS_REVIEW or APPROVED>
143+
144+
---
145+
146+
<!-- Add more changesets as needed, following the same format. -->
147+
````

.env.example

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
# PostgreSQL Configuration
12
POSTGRES_USER="cairocoder"
23
POSTGRES_PASSWORD="cairocoder"
3-
POSTGRES_DB="cairocoder"
4+
POSTGRES_DB="cairocoder"
5+
POSTGRES_HOST="postgres" # Use "postgres" for Docker, "localhost" for local development
6+
POSTGRES_PORT="5432" # Use 5432 for Docker, 5455 for local development
7+
POSTGRES_TABLE_NAME="documents"
8+
9+
# General Configuration
10+
PORT="3001"
11+
SIMILARITY_MEASURE="cosine"
12+
13+
# LLM Provider Configuration
14+
DEFAULT_CHAT_PROVIDER="gemini"
15+
DEFAULT_CHAT_MODEL="Gemini Flash 2.5"
16+
DEFAULT_FAST_CHAT_PROVIDER="gemini"
17+
DEFAULT_FAST_CHAT_MODEL="Gemini Flash 2.5"
18+
DEFAULT_EMBEDDING_PROVIDER="openai"
19+
DEFAULT_EMBEDDING_MODEL="Text embedding 3 large"
20+
21+
# LLM Provider API Keys
22+
OPENAI_API_KEY=""
23+
ANTHROPIC_API_KEY=""
24+
GEMINI_API_KEY=""
25+
DEEPSEEK_API_KEY=""
26+
GROQ_API_KEY=""
27+
28+
# Version Configuration
29+
STARKNET_FOUNDRY_VERSION="0.47.0"
30+
SCARB_VERSION="2.11.4"
31+
32+
# LangSmith Configuration (Optional)
33+
LANGSMITH_TRACING="false"
34+
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
35+
LANGSMITH_API_KEY=""
36+
LANGSMITH_OTEL_ENABLED="false"

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ jobs:
5252
- name: Build
5353
run: turbo build
5454

55-
- name: Setup test environment
56-
run: cp packages/agents/sample.config.toml packages/agents/config.toml
57-
5855
- name: Test
5956
run: turbo test
6057

.github/workflows/generate-embeddings.yml

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,48 +64,37 @@ jobs:
6464
run: |
6565
cargo install mdbook-i18n-helpers --locked --version 0.3.4
6666
67-
- name: Create config file
68-
run: |
69-
mkdir -p packages/agents
70-
cat > packages/agents/config.toml << 'EOL'
71-
[API_KEYS]
72-
OPENAI = "${{ secrets.OPENAI }}"
73-
ANTHROPIC = "${{ secrets.ANTHROPIC }}"
74-
GEMINI = "${{ secrets.GEMINI }}"
75-
76-
[VECTOR_DB]
77-
POSTGRES_USER = "${{ secrets.POSTGRES_USER }}"
78-
POSTGRES_HOST = "postgres"
79-
POSTGRES_ROOT_DB = "${{ secrets.POSTGRES_ROOT_DB }}"
80-
POSTGRES_PASSWORD = "${{ secrets.POSTGRES_PASSWORD }}"
81-
POSTGRES_PORT = "${{ secrets.POSTGRES_PORT }}"
82-
83-
[GENERAL]
84-
PORT = 3001
85-
SIMILARITY_MEASURE = "cosine"
86-
87-
[HOSTED_MODE]
88-
DEFAULT_CHAT_PROVIDER = "gemini"
89-
DEFAULT_CHAT_MODEL = "Gemini Flash 2.5"
90-
DEFAULT_FAST_CHAT_PROVIDER = "gemini"
91-
DEFAULT_FAST_CHAT_MODEL = "Gemini Flash 2.5"
92-
DEFAULT_EMBEDDING_PROVIDER = "openai"
93-
DEFAULT_EMBEDDING_MODEL = "Text embedding 3 large"
94-
95-
[VERSIONS]
96-
STARKNET_FOUNDRY = "0.37.0"
97-
SCARB = "2.9.2"
98-
EOL
99-
10067
- name: Create env file
10168
run: |
102-
mkdir -p packages/agents
103-
cat > packages/agents/.env << 'EOL'
104-
POSTGRES_USER = "${{ secrets.POSTGRES_USER }}"
105-
POSTGRES_HOST = "localhost"
106-
POSTGRES_ROOT_DB = "${{ secrets.POSTGRES_ROOT_DB }}"
107-
POSTGRES_PASSWORD = "${{ secrets.POSTGRES_PASSWORD }}"
108-
POSTGRES_PORT = "${{ secrets.POSTGRES_PORT }}"
69+
cat > .env << 'EOL'
70+
# Database Configuration
71+
POSTGRES_USER="${{ secrets.POSTGRES_USER }}"
72+
POSTGRES_PASSWORD="${{ secrets.POSTGRES_PASSWORD }}"
73+
POSTGRES_DB="${{ secrets.POSTGRES_DB }}"
74+
POSTGRES_HOST="postgres"
75+
POSTGRES_PORT="${{ secrets.POSTGRES_PORT }}"
76+
POSTGRES_TABLE_NAME="documents"
77+
78+
# General Configuration
79+
PORT="3001"
80+
SIMILARITY_MEASURE="cosine"
81+
82+
# Provider Configuration
83+
DEFAULT_CHAT_PROVIDER="gemini"
84+
DEFAULT_CHAT_MODEL="Gemini Flash 2.5"
85+
DEFAULT_FAST_CHAT_PROVIDER="gemini"
86+
DEFAULT_FAST_CHAT_MODEL="Gemini Flash 2.5"
87+
DEFAULT_EMBEDDING_PROVIDER="openai"
88+
DEFAULT_EMBEDDING_MODEL="Text embedding 3 large"
89+
90+
# API Keys
91+
OPENAI_API_KEY="${{ secrets.OPENAI }}"
92+
ANTHROPIC_API_KEY="${{ secrets.ANTHROPIC }}"
93+
GEMINI_API_KEY="${{ secrets.GEMINI }}"
94+
95+
# Version Configuration
96+
STARKNET_FOUNDRY_VERSION="0.47.0"
97+
SCARB_VERSION="2.11.4"
10998
EOL
11099
111100
- name: Generate embeddings

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ yarn-error.log
2222

2323
packages/ui/.env
2424

25-
# Config files
25+
# Config files (legacy)
2626
config.toml
2727
packages/backend/config.toml
2828

CLAUDE.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ Cairo Coder is an open-source Cairo language code generation service using Retri
6666

6767
### Configuration
6868

69-
- Copy `packages/agents/sample.config.toml` to `config.toml`
70-
- Required configurations:
71-
- LLM provider API keys (OPENAI, GEMINI, ANTHROPIC)
72-
- Database connection in [VECTOR_DB] section
73-
- Model selection in [PROVIDERS] section
74-
- Environment variables:
75-
- Root `.env`: PostgreSQL initialization (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB)
76-
- `packages/backend/.env`: Optional LangSmith tracing configuration
69+
- All sensitive configuration is managed via environment variables
70+
- Copy `.env.example` to `.env` in the root directory
71+
- Required environment variables:
72+
- Database credentials: POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, POSTGRES_HOST, POSTGRES_PORT
73+
- LLM provider API keys: OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY (at least one required)
74+
- Optional: LANGSMITH_API_KEY for tracing
7775

7876
### Database Architecture
7977

0 commit comments

Comments
 (0)