cpkb 2.0.1__tar.gz

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.
cpkb-2.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aarav Shah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cpkb-2.0.1/PKG-INFO ADDED
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: cpkb
3
+ Version: 2.0.1
4
+ Summary: A terminal-first Competitive Programming Knowledge Base
5
+ Author: Aarav Shah
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Aaravshah2907/cpkb
8
+ Project-URL: Repository, https://github.com/Aaravshah2907/cpkb
9
+ Project-URL: Issues, https://github.com/Aaravshah2907/cpkb/issues
10
+ Project-URL: Changelog, https://github.com/Aaravshah2907/cpkb/releases
11
+ Keywords: competitive-programming,snippets,knowledge-base,terminal,tui
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Environment :: Console
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Classifier: Topic :: Utilities
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: textual>=0.47.0
24
+ Requires-Dist: cryptography>=41.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: build>=1.2; extra == "dev"
27
+ Requires-Dist: pytest>=8.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
29
+ Requires-Dist: pytest-mock>=3.12; extra == "dev"
30
+ Requires-Dist: twine>=5.0; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # Competitive Programming Knowledge Base (CPKB)
34
+
35
+ ![CPKB TUI Gallery](https://raw.githubusercontent.com/Aaravshah2907/cpkb/main/intro-image.png)
36
+
37
+ CPKB is a local, terminal-first knowledge base designed to store, search, and track usages of competitive programming snippets, algorithms, and tricks. It uses SQLite for storage, keeping your snippets incredibly fast and perfectly organised.
38
+
39
+ ## Version 2.0 Features
40
+
41
+ - **Store snippets**: Add code snippets with metadata like title, use case, and tags.
42
+ - **Search snippets**: Full-text search across titles, descriptions, tags, and code.
43
+ - **Track usage**: Record every time you use a snippet in a problem, linking to the file and optionally taking notes.
44
+ - **Textual TUI**: A beautiful terminal UI for browsing and copying your snippets.
45
+ - **FZF Integration**: Fuzzy find snippets directly in the terminal.
46
+ - **Snippet Insertion**: Instantly copy code to the clipboard or append to files.
47
+ - **Spaced Repetition (SM-2)**: Revise your knowledge base using the `revise` command with a true SM-2 spaced-repetition algorithm that tracks ease, interval, and repetitions per snippet.
48
+ - **Password-based Encryption**: Encrypt your database at rest with a password (PBKDF2-HMAC-SHA256 key derivation). No keys stored on disk.
49
+ - **XDG Base Directory compliant**: Stores your data safely in `~/.local/share/cpkb`.
50
+
51
+ ## Installation
52
+
53
+ Install CPKB with `pipx`:
54
+
55
+ ```bash
56
+ pipx install cpkb
57
+ ```
58
+
59
+ Or install it with `pip`:
60
+
61
+ ```bash
62
+ python -m pip install cpkb
63
+ ```
64
+
65
+ ### Homebrew
66
+
67
+ After the first release is published, macOS and Linux users can install from the project tap:
68
+
69
+ ```bash
70
+ brew tap Aaravshah2907/cpkb
71
+ brew install cpkb
72
+ ```
73
+
74
+ Until the tap is live, the formula template lives in `Formula/cpkb.rb`.
75
+
76
+ ### From Source
77
+
78
+ ```bash
79
+ git clone https://github.com/Aaravshah2907/cpkb.git
80
+ cd cpkb
81
+ pip install -e .
82
+ ```
83
+
84
+ ### Local Development & Testing
85
+
86
+ If you wish to contribute to the codebase or run the unit tests locally to verify the CLI and TUI functionality, set up a virtual environment and run `pytest`:
87
+
88
+ ```bash
89
+ # 1. Create and activate a virtual environment
90
+ python3 -m venv venv
91
+ source venv/bin/activate # On Windows use: venv\Scripts\activate
92
+
93
+ # 2. Install CPKB and test dependencies
94
+ python -m pip install -e ".[dev]"
95
+
96
+ # 3. Run the test suite
97
+ pytest
98
+ ```
99
+
100
+ ## Platform‑specific dependencies
101
+
102
+ | Platform | Clipboard utility | Fuzzy finder |
103
+ |----------|---------------------|--------------------------------------------|
104
+ | macOS | `pbcopy` (built‑in) | `brew install fzf` |
105
+ | Linux | `xclip` or `xsel` | `sudo apt-get install fzf` |
106
+ | Windows | `clip` (built‑in) | `scoop install fzf` or `choco install fzf` |
107
+
108
+ ## Usage
109
+
110
+ Here are the commands available in Version 2.0:
111
+
112
+ ### Core V1 Commands
113
+
114
+ - `cpkb add`: Add a new snippet interactively.
115
+ - `cpkb list`: List all snippets.
116
+ - `cpkb show <id>`: Show details, code, and usages of a specific snippet.
117
+ - `cpkb search <query>`: Search for snippets matching multiple words.
118
+ - `cpkb use <id> <file>`: Record the usage of a snippet in a specific file.
119
+ - `cpkb usages <id>`: List all recorded usages for a snippet.
120
+ - `cpkb stats`: Show basic database statistics.
121
+ - `cpkb random`: Show a random snippet for review or practice.
122
+ - `cpkb edit <id>`: Edit a snippet's metadata and code in your default `$EDITOR`.
123
+ - `cpkb edit-usage <id>`: Edit a past usage record.
124
+ - `cpkb delete <id>`: Delete a snippet permanently.
125
+ - `cpkb recent`: Show the 10 most recently added snippets.
126
+ - `cpkb export`: Export your entire knowledge base to a single Markdown file.
127
+ - `cpkb export-db [--encrypted]`: Export your SQLite database, optionally encrypted with a password.
128
+ - `cpkb import <file-or-url>`: Append snippets from a CPKB `db`, `json`, `md`, or `html` export.
129
+ - `cpkb import --defaults`: Import bundled C++ STL competitive-programming cheatsheets with special `cp_` IDs.
130
+ - `cpkb import --list-defaults`: Preview the bundled cheatsheets before importing.
131
+ - `cpkb backup`: Manually trigger a backup of the SQLite database.
132
+
133
+ ### New V2 Commands
134
+
135
+ - `cpkb tui`: Launch the interactive Textual TUI (press `c` to copy a snippet).
136
+ - `cpkb fzf`: Interactively fuzzy search snippets using `fzf`.
137
+ - `cpkb copy <id> [-f <file>]`: Instantly copy the snippet's code to your system clipboard (uses `pbcopy` on macOS, `xclip`/`xsel` on Linux, `clip` on Windows) or append to a file.
138
+ - `cpkb revise`: Start a spaced-repetition session — the SM-2 algorithm selects the most overdue snippet, shows the title, then reveals the code. Rate your recall (0–5) to schedule the next review.
139
+ - `cpkb srs-stats`: Show spaced-repetition statistics (total reviewed, due now, avg ease factor).
140
+ - `cpkb encrypt-db`: Encrypt the database with a password (PBKDF2 + Fernet). No key files are stored.
141
+ - `cpkb decrypt-db`: Decrypt the database by entering your password.
142
+
143
+ ## Directory Structure
144
+
145
+ Data is kept completely separate from the code repo. The application automatically creates the required directories on first run:
146
+
147
+ ```txt
148
+ ~/.local/share/cpkb/
149
+ ├── snippets.db
150
+ ├── attachments/
151
+ ├── backups/
152
+ ├── exports/
153
+ ├── imports/
154
+ └── logs/
155
+ ```
156
+
157
+ ## Requirements
158
+
159
+ - Python 3.11+
160
+ - `textual`
161
+ - `cryptography` (for `encrypt-db` / `decrypt-db`)
162
+ - `fzf` (Optional, for `cpkb fzf`)
163
+ - A platform clipboard helper: `pbcopy` on macOS, `xclip` or `xsel` on Linux, `clip` on Windows
164
+
165
+ ## License
166
+
167
+ MIT License.
cpkb-2.0.1/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # Competitive Programming Knowledge Base (CPKB)
2
+
3
+ ![CPKB TUI Gallery](https://raw.githubusercontent.com/Aaravshah2907/cpkb/main/intro-image.png)
4
+
5
+ CPKB is a local, terminal-first knowledge base designed to store, search, and track usages of competitive programming snippets, algorithms, and tricks. It uses SQLite for storage, keeping your snippets incredibly fast and perfectly organised.
6
+
7
+ ## Version 2.0 Features
8
+
9
+ - **Store snippets**: Add code snippets with metadata like title, use case, and tags.
10
+ - **Search snippets**: Full-text search across titles, descriptions, tags, and code.
11
+ - **Track usage**: Record every time you use a snippet in a problem, linking to the file and optionally taking notes.
12
+ - **Textual TUI**: A beautiful terminal UI for browsing and copying your snippets.
13
+ - **FZF Integration**: Fuzzy find snippets directly in the terminal.
14
+ - **Snippet Insertion**: Instantly copy code to the clipboard or append to files.
15
+ - **Spaced Repetition (SM-2)**: Revise your knowledge base using the `revise` command with a true SM-2 spaced-repetition algorithm that tracks ease, interval, and repetitions per snippet.
16
+ - **Password-based Encryption**: Encrypt your database at rest with a password (PBKDF2-HMAC-SHA256 key derivation). No keys stored on disk.
17
+ - **XDG Base Directory compliant**: Stores your data safely in `~/.local/share/cpkb`.
18
+
19
+ ## Installation
20
+
21
+ Install CPKB with `pipx`:
22
+
23
+ ```bash
24
+ pipx install cpkb
25
+ ```
26
+
27
+ Or install it with `pip`:
28
+
29
+ ```bash
30
+ python -m pip install cpkb
31
+ ```
32
+
33
+ ### Homebrew
34
+
35
+ After the first release is published, macOS and Linux users can install from the project tap:
36
+
37
+ ```bash
38
+ brew tap Aaravshah2907/cpkb
39
+ brew install cpkb
40
+ ```
41
+
42
+ Until the tap is live, the formula template lives in `Formula/cpkb.rb`.
43
+
44
+ ### From Source
45
+
46
+ ```bash
47
+ git clone https://github.com/Aaravshah2907/cpkb.git
48
+ cd cpkb
49
+ pip install -e .
50
+ ```
51
+
52
+ ### Local Development & Testing
53
+
54
+ If you wish to contribute to the codebase or run the unit tests locally to verify the CLI and TUI functionality, set up a virtual environment and run `pytest`:
55
+
56
+ ```bash
57
+ # 1. Create and activate a virtual environment
58
+ python3 -m venv venv
59
+ source venv/bin/activate # On Windows use: venv\Scripts\activate
60
+
61
+ # 2. Install CPKB and test dependencies
62
+ python -m pip install -e ".[dev]"
63
+
64
+ # 3. Run the test suite
65
+ pytest
66
+ ```
67
+
68
+ ## Platform‑specific dependencies
69
+
70
+ | Platform | Clipboard utility | Fuzzy finder |
71
+ |----------|---------------------|--------------------------------------------|
72
+ | macOS | `pbcopy` (built‑in) | `brew install fzf` |
73
+ | Linux | `xclip` or `xsel` | `sudo apt-get install fzf` |
74
+ | Windows | `clip` (built‑in) | `scoop install fzf` or `choco install fzf` |
75
+
76
+ ## Usage
77
+
78
+ Here are the commands available in Version 2.0:
79
+
80
+ ### Core V1 Commands
81
+
82
+ - `cpkb add`: Add a new snippet interactively.
83
+ - `cpkb list`: List all snippets.
84
+ - `cpkb show <id>`: Show details, code, and usages of a specific snippet.
85
+ - `cpkb search <query>`: Search for snippets matching multiple words.
86
+ - `cpkb use <id> <file>`: Record the usage of a snippet in a specific file.
87
+ - `cpkb usages <id>`: List all recorded usages for a snippet.
88
+ - `cpkb stats`: Show basic database statistics.
89
+ - `cpkb random`: Show a random snippet for review or practice.
90
+ - `cpkb edit <id>`: Edit a snippet's metadata and code in your default `$EDITOR`.
91
+ - `cpkb edit-usage <id>`: Edit a past usage record.
92
+ - `cpkb delete <id>`: Delete a snippet permanently.
93
+ - `cpkb recent`: Show the 10 most recently added snippets.
94
+ - `cpkb export`: Export your entire knowledge base to a single Markdown file.
95
+ - `cpkb export-db [--encrypted]`: Export your SQLite database, optionally encrypted with a password.
96
+ - `cpkb import <file-or-url>`: Append snippets from a CPKB `db`, `json`, `md`, or `html` export.
97
+ - `cpkb import --defaults`: Import bundled C++ STL competitive-programming cheatsheets with special `cp_` IDs.
98
+ - `cpkb import --list-defaults`: Preview the bundled cheatsheets before importing.
99
+ - `cpkb backup`: Manually trigger a backup of the SQLite database.
100
+
101
+ ### New V2 Commands
102
+
103
+ - `cpkb tui`: Launch the interactive Textual TUI (press `c` to copy a snippet).
104
+ - `cpkb fzf`: Interactively fuzzy search snippets using `fzf`.
105
+ - `cpkb copy <id> [-f <file>]`: Instantly copy the snippet's code to your system clipboard (uses `pbcopy` on macOS, `xclip`/`xsel` on Linux, `clip` on Windows) or append to a file.
106
+ - `cpkb revise`: Start a spaced-repetition session — the SM-2 algorithm selects the most overdue snippet, shows the title, then reveals the code. Rate your recall (0–5) to schedule the next review.
107
+ - `cpkb srs-stats`: Show spaced-repetition statistics (total reviewed, due now, avg ease factor).
108
+ - `cpkb encrypt-db`: Encrypt the database with a password (PBKDF2 + Fernet). No key files are stored.
109
+ - `cpkb decrypt-db`: Decrypt the database by entering your password.
110
+
111
+ ## Directory Structure
112
+
113
+ Data is kept completely separate from the code repo. The application automatically creates the required directories on first run:
114
+
115
+ ```txt
116
+ ~/.local/share/cpkb/
117
+ ├── snippets.db
118
+ ├── attachments/
119
+ ├── backups/
120
+ ├── exports/
121
+ ├── imports/
122
+ └── logs/
123
+ ```
124
+
125
+ ## Requirements
126
+
127
+ - Python 3.11+
128
+ - `textual`
129
+ - `cryptography` (for `encrypt-db` / `decrypt-db`)
130
+ - `fzf` (Optional, for `cpkb fzf`)
131
+ - A platform clipboard helper: `pbcopy` on macOS, `xclip` or `xsel` on Linux, `clip` on Windows
132
+
133
+ ## License
134
+
135
+ MIT License.
@@ -0,0 +1,54 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cpkb"
7
+ version = "2.0.1"
8
+ authors = [
9
+ { name="Aarav Shah" },
10
+ ]
11
+ description = "A terminal-first Competitive Programming Knowledge Base"
12
+ readme = "README.md"
13
+ requires-python = ">=3.11"
14
+ license = "MIT"
15
+ license-files = ["LICENSE"]
16
+ keywords = ["competitive-programming", "snippets", "knowledge-base", "terminal", "tui"]
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Operating System :: OS Independent",
23
+ "Environment :: Console",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Topic :: Utilities",
26
+ ]
27
+ dependencies = [
28
+ "textual>=0.47.0",
29
+ "cryptography>=41.0",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "build>=1.2",
35
+ "pytest>=8.0",
36
+ "pytest-asyncio>=0.23",
37
+ "pytest-mock>=3.12",
38
+ "twine>=5.0",
39
+ ]
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/Aaravshah2907/cpkb"
43
+ Repository = "https://github.com/Aaravshah2907/cpkb"
44
+ Issues = "https://github.com/Aaravshah2907/cpkb/issues"
45
+ Changelog = "https://github.com/Aaravshah2907/cpkb/releases"
46
+
47
+ [project.scripts]
48
+ cpkb = "cpkb.cli:main"
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
cpkb-2.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ """
2
+ CPKB - Competitive Programming Knowledge Base
3
+ """
4
+
5
+ __version__ = "2.0.1"