learnchain 0.1.0 → 0.3.0

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/README.md CHANGED
@@ -2,69 +2,195 @@
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
- **LearnChain** is a terminal-based learning tool that helps you learn to code while using generative AI to build projects. It analyzes your Codex or Claude session logs and surfaces interactive quizzes in a beautiful terminal UI, reinforcing concepts as you work.
5
+ **LearnChain** is a terminal-based learning tool that turns your AI-assisted coding sessions into quizzes and deep-dive writeups you can review inside a Ratatui interface. It reads session history from Codex CLI or Claude Code, summarizes the work, generates structured lessons and saved markdown deep dives with Rig-backed LLM workflows, and tracks what you have learned over time.
6
+
7
+ ![Example Movie](readme_resources/example_mov.gif)
6
8
 
7
9
  ## Features
8
10
 
9
- - **Session Log Analysis**: Parse and learn from your AI-assisted coding sessions
10
- - **Quiz Generation**: AI-powered quiz creation based on your actual coding patterns
11
- - **Configuration Management**: Persistent settings stored in `config/app_config.toml`
12
- - **Multi-platform Support**: Distributed via npm for easy installation across platforms
13
- - **Interactive TUI**: Built with [Ratatui](https://ratatui.rs) for a polished terminal experience
11
+ - Parse coding sessions from both Codex CLI and Claude Code
12
+ - Generate structured quizzes from your recent or selected historical sessions
13
+ - Generate saved session deep dives with reviewed source links and teaching narratives
14
+ - Support multiple LLM providers: OpenAI, Anthropic, and OpenRouter
15
+ - Use [Rig](https://github.com/0xPlaygrounds/rig) for provider integration and structured output generation
16
+ - Review lessons in an interactive terminal UI with quiz navigation and summaries
17
+ - Browse previously generated deep dives from inside the TUI
18
+ - Track learning history and first-attempt accuracy in a local SQLite database
19
+ - Browse an analytics dashboard for recent learning activity
20
+ - Persist configuration in `config/app_config.toml`
21
+ - Enable per-run debug logging with `--debug`
14
22
 
15
- ## Installation
23
+ ## Quick Start
16
24
 
17
- ### Via npm (Recommended)
25
+ ### Install from npm
18
26
 
19
27
  ```bash
20
28
  npm install -g learnchain
21
- npx learnchain --help
22
29
  ```
23
30
 
24
- ### From Source
31
+ ### Run from source
25
32
 
26
33
  ```bash
27
- git clone https://github.com/yourusername/learnchain.git
34
+ git clone https://github.com/normand1/learnchain
28
35
  cd learnchain
29
- cargo build --release
30
- ./target/release/learnchain
36
+ cargo build
37
+ cargo run
31
38
  ```
32
39
 
33
- ## Quick Start
40
+ ## Configure an LLM provider
41
+
42
+ LearnChain can generate quizzes with OpenAI, Anthropic, or OpenRouter. Provider selection, model selection, and API keys are managed in the in-app Config view.
43
+
44
+ ### Option 1: configure inside the TUI
45
+
46
+ 1. Start LearnChain.
47
+ 2. Open `Configure details`.
48
+ 3. Choose the provider you want to use.
49
+ 4. Set the provider-specific model or API key fields.
50
+ 5. Save and return to the menu.
51
+
52
+ ### Option 2: configure keys from the CLI
53
+
54
+ ```bash
55
+ learnchain --set-openai-key <key>
56
+ learnchain --set-anthropic-key <key>
57
+ learnchain --set-openrouter-key <key>
58
+ ```
59
+
60
+ You can also clear them:
61
+
62
+ ```bash
63
+ learnchain --clear-openai-key
64
+ learnchain --clear-anthropic-key
65
+ learnchain --clear-openrouter-key
66
+ ```
67
+
68
+ You can also configure a generic deep-dive export destination for future document repository integrations:
69
+
70
+ ```bash
71
+ learnchain --set-document-repository notion
72
+ learnchain --set-document-repository-target database/abcd1234
73
+ learnchain --clear-document-repository
74
+ learnchain --clear-document-repository-target
75
+ learnchain --set-notion-api-token <token>
76
+ learnchain --clear-notion-api-token
77
+ ```
78
+
79
+ ## Codex Integration
80
+
81
+ LearnChain can generate a deep dive for the active Codex session without opening the TUI.
82
+
83
+ Prerequisites:
84
+
85
+ - Install LearnChain and configure an LLM provider.
86
+ - Run the command from a Codex session if you want LearnChain to resolve `CODEX_THREAD_ID` automatically.
87
+
88
+ Generate a deep dive for the active Codex session:
89
+
90
+ ```bash
91
+ learnchain --generate-codex-deep-dive
92
+ ```
93
+
94
+ Target a specific Codex session id explicitly:
95
+
96
+ ```bash
97
+ learnchain --generate-codex-deep-dive --codex-thread-id <thread-id>
98
+ ```
99
+
100
+ The command writes the markdown artifact to `output/deep-dives/` and prints the saved path, title, goal, and accomplishment bullets to stdout for Codex to relay back in chat.
101
+
102
+ To generate and immediately export the deep dive to the configured document repository:
34
103
 
35
- 1. **Configure your OpenAI API key** (required for quiz generation):
36
- ```bash
37
- npx learnchain --set-openai-key sk-...
38
- ```
104
+ ```bash
105
+ learnchain --generate-codex-deep-dive --export-to-document-repository
106
+ ```
107
+
108
+ That uses the same repository settings as the Library export flow and prints the repository label plus remote URL when the export succeeds.
109
+
110
+ To install the real Codex skill into your local Codex skills directory:
111
+
112
+ ```bash
113
+ learnchain --install-codex-deep-dive-skill
114
+ ```
115
+
116
+ This writes the bundled `learnchain-deep-dive` skill into `$CODEX_HOME/skills` when `CODEX_HOME` is set, or `~/.codex/skills` otherwise. Restart Codex after installation so it reloads available skills.
117
+
118
+ If you want the copy/paste custom-command template as well, print it with:
119
+
120
+ ```bash
121
+ learnchain --print-codex-deep-dive-action
122
+ ```
123
+
124
+ That template tells Codex to run LearnChain with `--codex-thread-id "$CODEX_THREAD_ID"` and return the saved path plus a short summary.
125
+
126
+ ## Usage
127
+
128
+ The main menu currently supports these core flows:
129
+
130
+ - Select a historical session, grouped by project, and generate a quiz from it
131
+ - Select a historical session, grouped by project, and generate a session deep dive from it
132
+ - Open the Library view to browse previously saved deep dives and quiz artifacts
133
+ - From the Library view, press `e` to send the selected artifact to the configured document repository
134
+ - Open saved deep-dive history and reload previous markdown artifacts
135
+ - Open the analytics dashboard
136
+ - Configure provider, model, and app defaults
137
+
138
+ Quiz JSON artifacts can be written to `output/` when `Write quiz artifacts to output` is enabled in the Config view. Session deep dives are always saved to `output/deep-dives/`. The Config view now includes a `Document repository` selector. When `Notion` is selected, LearnChain shows separate fields for `Notion destination` and `Notion API token`. The Notion destination should be the target database/page ID or the full Notion URL, and the UI explains how to create an internal integration and connect it to the database. Library exports create a new page under that configured Notion destination and send the selected deep dive or quiz content into it. Learning history is stored in `output/learning_history.sqlite`.
39
139
 
40
- Or configure it directly in the TUI: Config view → "OpenAI API key" → press Enter to edit
140
+ ## Debug Logging
41
141
 
42
- 2. **Launch the terminal UI**:
43
- ```bash
44
- cargo run
45
- # or if installed via npm:
46
- npx learnchain
47
- ```
142
+ To troubleshoot runtime issues, start the app with the debug flag:
48
143
 
49
- 3. Navigate the menu to load session logs, configure defaults, and start learning!
144
+ ```bash
145
+ cargo run -- --debug
146
+ ```
147
+
148
+ If you are running the installed binary directly:
149
+
150
+ ```bash
151
+ learnchain --debug
152
+ ```
153
+
154
+ This forces the app to write debug logs to:
155
+
156
+ ```text
157
+ output/learnchain-debug.log
158
+ ```
159
+
160
+ The log file is truncated at the start of each debug run so each session starts with a clean log.
50
161
 
51
162
  ## Development
52
163
 
53
164
  ### Prerequisites
54
165
 
55
- - Rust (edition 2024)
56
- - Node.js >= 16 (for npm distribution)
166
+ - Rust
167
+ - Node.js >= 16 for npm distribution tasks
57
168
  - Cargo
58
169
 
59
- ### Build Commands
170
+ ### Common commands
60
171
 
61
172
  ```bash
62
- # Compile the TUI
173
+ # Build the TUI
63
174
  cargo build
64
175
 
65
176
  # Run the application
66
177
  cargo run
67
178
 
179
+ # Run with runtime debug logging
180
+ cargo run -- --debug
181
+
182
+ # Generate a deep dive for the active Codex session
183
+ cargo run -- --generate-codex-deep-dive
184
+
185
+ # Generate and export a deep dive for the active Codex session
186
+ cargo run -- --generate-codex-deep-dive --export-to-document-repository
187
+
188
+ # Install the bundled Codex skill
189
+ cargo run -- --install-codex-deep-dive-skill
190
+
191
+ # Print the Codex custom command template
192
+ cargo run -- --print-codex-deep-dive-action
193
+
68
194
  # Run tests with output
69
195
  cargo test -- --nocapture
70
196
 
@@ -72,55 +198,69 @@ cargo test -- --nocapture
72
198
  cargo fmt
73
199
  cargo clippy --all-targets --all-features
74
200
 
75
- # Build release binary for npm distribution
201
+ # Build the npm distribution
76
202
  npm run build
77
203
  ```
78
204
 
79
- ### Project Structure
205
+ ## Project Structure
80
206
 
81
- ```
207
+ ```text
82
208
  learnchain/
83
209
  ├── src/
84
- │ ├── main.rs # Entry point and app state
85
- │ ├── ai_manager.rs # AI/LLM integration
86
- │ ├── config.rs # Configuration management
87
- │ ├── session_manager.rs # AI coding tool (Claude/Codex) log processing
210
+ │ ├── main.rs # Entry point, app state, CLI handling
211
+ │ ├── config.rs # Configuration and provider/model resolution
212
+ │ ├── llm/ # Rig-backed learning and deep-dive generation
213
+ ├── mod.rs # App-facing orchestration and background task handling
214
+ │ │ ├── backend.rs # Shared Rig provider clients and typed extraction
215
+ │ │ ├── deep_dive.rs # Session deep-dive workflow and markdown assembly
216
+ │ │ ├── deep_dive_types.rs # Structured deep-dive payloads and artifact metadata
217
+ │ │ └── types.rs # Structured quiz payloads and usage types
218
+ │ ├── knowledge_store.rs # SQLite-backed learning history and analytics
219
+ │ ├── session_manager.rs # Session orchestration and loading
220
+ │ ├── session_sources/ # Session source implementations
221
+ │ │ ├── mod.rs # Shared session traits and types
222
+ │ │ ├── codex.rs # Codex CLI parsing
223
+ │ │ └── claude.rs # Claude Code parsing
88
224
  │ ├── ui_renderer.rs # Terminal UI rendering
89
- └── view_managers/ # View-specific logic
225
+ ├── log_util.rs # Debug logging support
226
+ │ └── view_managers/ # View-specific interaction logic
90
227
  ├── config/ # Runtime configuration
228
+ ├── output/ # Optional generated artifacts, logs, and SQLite data
91
229
  ├── test_fixtures/ # Test fixtures
92
230
  ├── scripts/ # Build and install helpers
93
231
  └── dist/ # npm distribution files
94
232
  ```
95
233
 
96
- See [AGENTS.md](AGENTS.md) for detailed development guidelines.
234
+ See [AGENTS.md](AGENTS.md) for repository-specific development guidelines.
97
235
 
98
236
  ## Configuration
99
237
 
100
- LearnChain stores configuration in `config/app_config.toml`. Key settings include:
238
+ LearnChain stores settings in `config/app_config.toml`. Relevant settings include:
101
239
 
102
- - OpenAI API key (required for quiz generation)
103
- - Default session log paths
104
- - UI preferences
240
+ - session source selection
241
+ - default event sampling and quiz sizing
242
+ - active LLM provider
243
+ - provider-specific model and API key fields
244
+ - selected document repository and its repository-specific target
245
+ - Notion API token for Notion-backed document targets
246
+ - whether quiz JSON artifacts should be persisted to disk
105
247
 
106
248
  ## Contributing
107
249
 
108
- Contributions are welcome! Please:
250
+ Contributions are welcome. Before opening a PR:
109
251
 
110
- 1. Fork the repository
111
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
112
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
113
- 4. Push to the branch (`git push origin feature/amazing-feature`)
114
- 5. Open a Pull Request
252
+ 1. Run `cargo fmt`
253
+ 2. Run `cargo clippy --all-targets --all-features`
254
+ 3. Run `cargo test -- --nocapture`
255
+ 4. Note any UI changes, config changes, or risky behavior changes in the PR description
115
256
 
116
257
  See [AGENTS.md](AGENTS.md) for coding standards and testing guidelines.
117
258
 
118
259
  ## License
119
260
 
120
- Copyright (c) Dave Norman <david.norman.w@gmail.com>
121
-
122
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
261
+ This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
123
262
 
124
263
  ## Acknowledgments
125
264
 
126
- - Built with [Ratatui](https://ratatui.rs) - Rust TUI framework
265
+ - Built with [Ratatui](https://ratatui.rs)
266
+ - LLM integration powered by [Rig](https://github.com/0xPlaygrounds/rig)
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,21 +1,17 @@
1
1
  {
2
2
  "name": "learnchain",
3
- "version": "0.1.0",
4
- "description": "Terminal-based learning tool that analyzes AI coding sessions and generates interactive quizzes",
5
- "license": "MIT",
3
+ "version": "0.3.0",
6
4
  "author": "Dave Norman <david.norman.w@gmail.com>",
7
- "bin": {
8
- "learnchain": "dist/learnchain.js"
9
- },
10
5
  "repository": {
11
6
  "type": "git",
12
7
  "url": "git+https://github.com/normand1/learnchain"
13
8
  },
14
- "scripts": {
15
- "build": "cargo build --release",
16
- "build:all": "echo 'Use GitHub Actions workflow to build all platform binaries'",
17
- "postinstall": "node scripts/install.js",
18
- "prepublishOnly": "node scripts/generate-launcher.js"
9
+ "bin": {
10
+ "learnchain": "dist/learnchain.js"
11
+ },
12
+ "description": "Terminal-based learning tool that analyzes AI coding sessions and generates interactive quizzes",
13
+ "engines": {
14
+ "node": ">=16"
19
15
  },
20
16
  "files": [
21
17
  "dist/",
@@ -36,7 +32,11 @@
36
32
  "education",
37
33
  "rust"
38
34
  ],
39
- "engines": {
40
- "node": ">=16"
35
+ "license": "MIT",
36
+ "scripts": {
37
+ "build": "cargo build --release",
38
+ "build:all": "echo 'Use GitHub Actions workflow to build all platform binaries'",
39
+ "postinstall": "node scripts/install.js",
40
+ "prepublishOnly": "node scripts/generate-launcher.js"
41
41
  }
42
42
  }
@@ -59,3 +59,5 @@ if (platform !== 'win32') {
59
59
  console.log(`✓ learnchain installed successfully for ${platform}-${arch}`);
60
60
  console.log('\nRun: npx learnchain --help');
61
61
  console.log('Tip: Run `npx learnchain --set-openai-key <your-key>` to configure your OpenAI API key.');
62
+ console.log('Codex tip: Run `npx learnchain --install-codex-deep-dive-skill` to install the LearnChain Codex skill.');
63
+ console.log('Codex tip: Run `npx learnchain --print-codex-deep-dive-action` to print the Codex custom command template.');