Skip to content

Commit a620949

Browse files
committed
chore: further wip of scarleet cli
1 parent 52b5064 commit a620949

23 files changed

+1443
-54
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var/
2828
*.egg-info/
2929
.installed.cfg
3030
*.egg
31+
.env
3132

3233
# Installer logs
3334
pip-log.txt

INSTALL.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Scarleet CLI Installation (Local, Editable)
2+
3+
You can install Scarleet as a CLI tool locally, so you can run `scarleet` from anywhere on your system.
4+
5+
## 1. Install in Editable Mode
6+
7+
From the root of your project, run:
8+
9+
```sh
10+
pip install --editable .
11+
```
12+
13+
This will make the `scarleet` command available globally (in your environment).
14+
15+
## 2. Install dependencies
16+
17+
You can install all required dependencies for Scarleet using either:
18+
19+
```sh
20+
pip install -r requirements.txt
21+
```
22+
23+
or, for modern Python packaging:
24+
25+
```sh
26+
pip install .
27+
```
28+
29+
Both methods will set up everything needed for the CLI.
30+
31+
## 3. Usage
32+
33+
After installation, you can run:
34+
35+
```sh
36+
scarleet --help
37+
```
38+
39+
or any subcommand, e.g.:
40+
41+
```sh
42+
scarleet new <problem-slug>
43+
scarleet setup
44+
scarleet docgen <problem-slug>
45+
scarleet flashcards <problem-slug>
46+
scarleet status
47+
```
48+
49+
## 4. Uninstall
50+
51+
To remove the CLI:
52+
53+
```sh
54+
pip uninstall scarleet
55+
```
56+
57+
---
58+
59+
**Note:** This does not publish your package to PyPI. It only makes it available on your local machine for development and use.
60+
61+
62+
## OpenAI or Azure OpenAI Usage (Optional)
63+
64+
Scarleet can use either OpenAI or Azure OpenAI models for flashcard and docgen generation. Set the following environment variables in a `.env` file (recommended, and git-ignored):
65+
66+
### For OpenAI:
67+
```
68+
OPENAI_API_KEY=sk-...your-key...
69+
OPENAI_API_URL=https://api.openai.com/v1
70+
OPENAI_MODEL=gpt-4o
71+
OPENAI_API_VERSION=2024-06-01
72+
```
73+
74+
### For Azure OpenAI:
75+
```
76+
AZURE_API_KEY=your-azure-key
77+
AZURE_API_BASE=https://your-resource.openai.azure.com
78+
AZURE_DEPLOYMENT_NAME=your-deployment
79+
AZURE_API_VERSION=2024-06-01
80+
```
81+
82+
- Scarleet will auto-detect which provider to use based on your `.env`.
83+
- If neither is set, Scarleet will use your local SLM endpoint as a fallback.
84+
- Install dependencies for .env support:
85+
```sh
86+
pip install python-dotenv
87+
```
88+
- The `openai` Python package is required (see `requirements.txt`).
89+
90+
**Never commit your `.env` file or API keys to version control.**
91+
92+
---

README.md

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [File & Folder Structure](#file--folder-structure)
2222
* [Contributing & Support](#contributing--support)
2323
* [License](#license)
24+
* [OpenAI API Usage (Optional)](#openai-api-usage-optional)
2425

2526
## Overview
2627

@@ -67,27 +68,45 @@ This project is for anyone who wants to build a deep, recallable understanding o
6768
python main.py setup
6869
```
6970

71+
## Installation (Local CLI)
72+
73+
You can install all dependencies with either:
74+
75+
```sh
76+
pip install -r requirements.txt
77+
```
78+
79+
or, if you prefer PEP 621/modern Python packaging:
80+
81+
```sh
82+
pip install .
83+
```
84+
85+
Both methods will install all required packages for Scarleet.
86+
87+
See [INSTALL.md](INSTALL.md) for more details.
88+
7089
## The Workflow: A Quick Start
7190

7291
The entire process is designed to be simple and flow naturally with your practice.
7392

7493
1. **Create a New Problem:**
7594
```sh
76-
python main.py new <problem-slug>
77-
# Example: python main.py new two-sum
95+
scarleet new <problem-slug>
96+
# Example: scarleet new two-sum
7897
```
7998
2. **Solve It:** Navigate to the new `problems/[id]-[slug]` directory and write your solution in `solution.py`.
8099
3. **Generate Docs:** After your solution is accepted on LeetCode, let Scarleet document it for you.
81100
```sh
82-
python main.py docgen <problem-slug>
101+
scarleet docgen <problem-slug>
83102
```
84103
4. **Create Flashcards:** Turn your documented solution into study material.
85104
```sh
86-
python main.py flashcards <problem-slug>
105+
scarleet flashcards <problem-slug>
87106
```
88107
5. **Track Your Progress:** View a summary of all your solved problems and update the master `README.md`.
89108
```sh
90-
python main.py status --update-readme
109+
scarleet status --update-readme
91110
```
92111

93112
## Command Usage
@@ -123,6 +142,39 @@ All configuration is managed in the `scarleet.toml` file, which is created by th
123142
└── neetcode150.json # NeetCode 150 list
124143
```
125144

145+
146+
## OpenAI or Azure OpenAI Usage (Optional)
147+
148+
Scarleet can use either OpenAI or Azure OpenAI models (like GPT-4, GPT-3.5, etc.) for generating flashcards and documentation. To enable this, set the following environment variables in a `.env` file (which should NOT be committed to version control):
149+
150+
### For OpenAI:
151+
```
152+
OPENAI_API_KEY=sk-...your-key...
153+
OPENAI_API_URL=https://api.openai.com/v1
154+
OPENAI_MODEL=gpt-4o
155+
OPENAI_API_VERSION=2024-06-01
156+
```
157+
158+
### For Azure OpenAI:
159+
```
160+
AZURE_API_KEY=your-azure-key
161+
AZURE_API_BASE=https://your-resource.openai.azure.com
162+
AZURE_DEPLOYMENT_NAME=your-deployment
163+
AZURE_API_VERSION=2024-06-01
164+
```
165+
166+
- Scarleet will auto-detect which provider to use based on your `.env`.
167+
- If neither is set, Scarleet will use your local SLM endpoint as a fallback.
168+
- Install dependencies for .env support:
169+
```sh
170+
pip install python-dotenv
171+
```
172+
- The `openai` Python package is required (see `requirements.txt`).
173+
174+
**Never commit your `.env` file or API keys to version control.**
175+
176+
---
177+
126178
## Contributing & Support
127179

128180
Contributions, suggestions, and improvements are welcome! Please open an issue or PR. By contributing, you agree that your contributions will be licensed under the GNU General Public License v3.0.

problems/1-two-sum/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Problem 1: Two Sum
2+
3+
## Link
4+
- [Two Sum](https://leetcode.com/problems/two-sum/)
5+
6+
## Intuition
7+
By using a hash map to store previously seen numbers and their indices, we can efficiently check if the complement (target - current number) exists.
8+
9+
## Approach
10+
Iterate through the list, calculate the complement for each number, check if the complement is already in the hash map, and if so, return the indices; otherwise, store the current number and its index in the hash map.
11+
12+
## Complexity
13+
- Time: `O(n)`
14+
- Space: `O(n)`
15+
16+
## Notes
17+
- Utilizes a hash map for constant time look-ups.
18+
- Returns indices as soon as the pair is found, ensuring only one valid pair is returned.
19+
- Handles edge cases where no valid pair exists by implicit assumption that input guarantees a solution.

problems/1-two-sum/metadata.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"title": "Two Sum",
3+
"slug": "two-sum",
4+
"frontend_id": "1",
5+
"url": "https://leetcode.com/problems/two-sum/",
6+
"difficulty": "Easy",
7+
"tags": [
8+
"Array",
9+
"Hash Table"
10+
],
11+
"lists": [
12+
"NeetCode 150",
13+
"Blind 75"
14+
],
15+
"status": "documented",
16+
"last_updated": "2025-06-14T19:54:27.246799Z"
17+
}

problems/1-two-sum/solution.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
3+
# LeetCode Problem: Two Sum
4+
# URL: https://leetcode.com/problems/two-sum/
5+
6+
from typing import List
7+
8+
9+
class Solution:
10+
def twoSum(self, nums: List[int], target: int) -> List[int]:
11+
val_to_index = {}
12+
13+
for i, num in enumerate(nums):
14+
diff = target - num
15+
if diff in val_to_index:
16+
return [val_to_index[diff], i]
17+
else:
18+
val_to_index[num] = i

problems/1-two-sum/test_cases.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
from solution import Solution
3+
4+
5+
class TestSolution(unittest.TestCase):
6+
def setUp(self):
7+
self.solution = Solution()
8+
9+
def test_example_1(self):
10+
self.assertEqual(self.solution.twoSum([2, 7, 11, 15], 9), [0, 1])
11+
12+
13+
if __name__ == "__main__":
14+
unittest.main()

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "scarleet"
3+
version = "0.1.0"
4+
description = "Scarleet: CLI for LeetCode mastery and spaced repetition."
5+
authors = [
6+
{ name = "Scarowar" }
7+
]
8+
license = { file = "LICENSE" }
9+
readme = "README.md"
10+
requires-python = ">=3.9"
11+
dependencies = [
12+
"typer[all]",
13+
"rich",
14+
"toml",
15+
"requests",
16+
"openai",
17+
"python-dotenv"
18+
]
19+
20+
[project.scripts]
21+
scarleet = "scarleet.cli:app"
22+
23+
[tool.setuptools.packages.find]
24+
where = ["."]
25+
26+
[build-system]
27+
requires = ["setuptools>=61.0"]
28+
build-backend = "setuptools.build_meta"

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
typer[all]
2+
rich
3+
toml
4+
requests
5+
openai>=1.0.0
6+
python-dotenv

0 commit comments

Comments
 (0)