learnchain 0.2.2 → 0.4.1

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,64 +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
6
 
7
7
  ![Example Movie](readme_resources/example_mov.gif)
8
8
 
9
9
  ## Features
10
10
 
11
- - **Session Log Analysis**: Parse and learn from your AI-assisted coding sessions
12
- - **Quiz Generation**: AI-powered quiz creation based on your actual coding patterns
13
- - **Configuration Management**: Persistent settings stored in `config/app_config.toml`
14
- - **Multi-platform Support**: Distributed via npm for easy installation across platforms
15
- - **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`
16
22
 
17
23
  ## Quick Start
24
+
25
+ ### Install from npm
26
+
18
27
  ```bash
19
28
  npm install -g learnchain
20
29
  ```
21
- #### Two options to set API Key:
22
- Option 1:
23
- Start learnchain with
30
+
31
+ ### Run from source
32
+
24
33
  ```bash
25
- learnchain
34
+ git clone https://github.com/normand1/learnchain
35
+ cd learnchain
36
+ cargo build
37
+ cargo run
26
38
  ```
27
- Then,
39
+
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
+
28
54
  ```bash
29
- "Configure details" -> "OpenAI API key:" -> (set your api key here) -> Enter -> m (menu)
55
+ learnchain config set openai-key <key>
56
+ learnchain config set anthropic-key <key>
57
+ learnchain config set openrouter-key <key>
30
58
  ```
31
59
 
32
- Option 2:
60
+ You can also clear them:
61
+
33
62
  ```bash
34
- learnchain --set-openai-key <key>
63
+ learnchain config clear openai-key
64
+ learnchain config clear anthropic-key
65
+ learnchain config clear openrouter-key
35
66
  ```
36
67
 
37
- ## Installation From Source
68
+ You can also configure a generic deep-dive export destination for future document repository integrations:
38
69
 
39
70
  ```bash
40
- git clone https://github.com/normand1/learnchain
41
- cd learnchain
42
- cargo build
43
- cargo run
71
+ learnchain config set repository notion
72
+ learnchain config set repository-target database/abcd1234
73
+ learnchain config clear repository
74
+ learnchain config clear repository-target
75
+ learnchain config set notion-token <token>
76
+ learnchain config clear notion-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. This can be an API-backed provider or a local CLI provider such as Codex CLI or Claude Code CLI.
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 deep-dive generate codex
92
+ ```
93
+
94
+ Target a specific Codex session id explicitly:
95
+
96
+ ```bash
97
+ learnchain deep-dive generate 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 the active coding agent to relay back in chat. The command still resolves Codex sessions, but generation uses whichever provider is selected in LearnChain config, including `Claude Code CLI`.
101
+
102
+ To generate and immediately export the deep dive to the configured document repository:
103
+
104
+ ```bash
105
+ learnchain deep-dive generate codex --export
44
106
  ```
45
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 skill install codex
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 action print codex
122
+ ```
123
+
124
+ That template tells Codex to run LearnChain with `--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`.
139
+
140
+ ## Debug Logging
141
+
142
+ To troubleshoot runtime issues, start the app with the debug flag:
143
+
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.
161
+
46
162
  ## Development
47
163
 
48
164
  ### Prerequisites
49
165
 
50
166
  - Rust
51
- - Node.js >= 16 (for npm distribution)
167
+ - Node.js >= 16 for npm distribution tasks
52
168
  - Cargo
53
169
 
54
- ### Build Commands
170
+ ### Common commands
55
171
 
56
172
  ```bash
57
- # Compile the TUI
173
+ # Build the TUI
58
174
  cargo build
59
175
 
60
176
  # Run the application
61
177
  cargo run
62
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 -- deep-dive generate codex
184
+
185
+ # Generate and export a deep dive for the active Codex session
186
+ cargo run -- deep-dive generate codex --export
187
+
188
+ # Install the bundled Codex skill
189
+ cargo run -- skill install codex
190
+
191
+ # Print the Codex custom command template
192
+ cargo run -- action print codex
193
+
63
194
  # Run tests with output
64
195
  cargo test -- --nocapture
65
196
 
@@ -67,55 +198,69 @@ cargo test -- --nocapture
67
198
  cargo fmt
68
199
  cargo clippy --all-targets --all-features
69
200
 
70
- # Build release binary for npm distribution
201
+ # Build the npm distribution
71
202
  npm run build
72
203
  ```
73
204
 
74
- ### Project Structure
205
+ ## Project Structure
75
206
 
76
- ```
207
+ ```text
77
208
  learnchain/
78
209
  ├── src/
79
- │ ├── main.rs # Entry point and app state
80
- │ ├── ai_manager.rs # AI/LLM integration
81
- │ ├── config.rs # Configuration management
82
- │ ├── 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
83
224
  │ ├── ui_renderer.rs # Terminal UI rendering
84
- └── view_managers/ # View-specific logic
225
+ ├── log_util.rs # Debug logging support
226
+ │ └── view_managers/ # View-specific interaction logic
85
227
  ├── config/ # Runtime configuration
228
+ ├── output/ # Optional generated artifacts, logs, and SQLite data
86
229
  ├── test_fixtures/ # Test fixtures
87
230
  ├── scripts/ # Build and install helpers
88
231
  └── dist/ # npm distribution files
89
232
  ```
90
233
 
91
- See [AGENTS.md](AGENTS.md) for detailed development guidelines.
234
+ See [AGENTS.md](AGENTS.md) for repository-specific development guidelines.
92
235
 
93
236
  ## Configuration
94
237
 
95
- LearnChain stores configuration in `config/app_config.toml`. Key settings include:
238
+ LearnChain stores settings in `config/app_config.toml`. Relevant settings include:
96
239
 
97
- - OpenAI API key (required for quiz generation)
98
- - Default session log paths
99
- - 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
100
247
 
101
248
  ## Contributing
102
249
 
103
- Contributions are welcome! Please:
250
+ Contributions are welcome. Before opening a PR:
104
251
 
105
- 1. Fork the repository
106
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
107
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
108
- 4. Push to the branch (`git push origin feature/amazing-feature`)
109
- 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
110
256
 
111
257
  See [AGENTS.md](AGENTS.md) for coding standards and testing guidelines.
112
258
 
113
259
  ## License
114
260
 
115
- Copyright (c) Dave Norman <david.norman.w@gmail.com>
116
-
117
- 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.
118
262
 
119
263
  ## Acknowledgments
120
264
 
121
- - 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.2.2",
4
- "description": "Terminal-based learning tool that analyzes AI coding sessions and generates interactive quizzes",
5
- "license": "MIT",
3
+ "version": "0.4.1",
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
  }
@@ -58,4 +58,6 @@ if (platform !== 'win32') {
58
58
 
59
59
  console.log(`✓ learnchain installed successfully for ${platform}-${arch}`);
60
60
  console.log('\nRun: npx learnchain --help');
61
- console.log('Tip: Run `npx learnchain --set-openai-key <your-key>` to configure your OpenAI API key.');
61
+ console.log('Tip: Run `npx learnchain config set openai-key <your-key>` to configure your OpenAI API key.');
62
+ console.log('Codex tip: Run `npx learnchain skill install codex` to install the LearnChain Codex skill.');
63
+ console.log('Codex tip: Run `npx learnchain action print codex` to print the Codex custom command template.');