learnchain 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 David Norman
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.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # LearnChain
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
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.
6
+
7
+ ## Features
8
+
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
14
+
15
+ ## Installation
16
+
17
+ ### Via npm (Recommended)
18
+
19
+ ```bash
20
+ npm install -g learnchain
21
+ npx learnchain --help
22
+ ```
23
+
24
+ ### From Source
25
+
26
+ ```bash
27
+ git clone https://github.com/yourusername/learnchain.git
28
+ cd learnchain
29
+ cargo build --release
30
+ ./target/release/learnchain
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ 1. **Configure your OpenAI API key** (required for quiz generation):
36
+ ```bash
37
+ npx learnchain --set-openai-key sk-...
38
+ ```
39
+
40
+ Or configure it directly in the TUI: Config view → "OpenAI API key" → press Enter to edit
41
+
42
+ 2. **Launch the terminal UI**:
43
+ ```bash
44
+ cargo run
45
+ # or if installed via npm:
46
+ npx learnchain
47
+ ```
48
+
49
+ 3. Navigate the menu to load session logs, configure defaults, and start learning!
50
+
51
+ ## Development
52
+
53
+ ### Prerequisites
54
+
55
+ - Rust (edition 2024)
56
+ - Node.js >= 16 (for npm distribution)
57
+ - Cargo
58
+
59
+ ### Build Commands
60
+
61
+ ```bash
62
+ # Compile the TUI
63
+ cargo build
64
+
65
+ # Run the application
66
+ cargo run
67
+
68
+ # Run tests with output
69
+ cargo test -- --nocapture
70
+
71
+ # Format and lint
72
+ cargo fmt
73
+ cargo clippy --all-targets --all-features
74
+
75
+ # Build release binary for npm distribution
76
+ npm run build
77
+ ```
78
+
79
+ ### Project Structure
80
+
81
+ ```
82
+ learnchain/
83
+ ├── 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
88
+ │ ├── ui_renderer.rs # Terminal UI rendering
89
+ │ └── view_managers/ # View-specific logic
90
+ ├── config/ # Runtime configuration
91
+ ├── test_fixtures/ # Test fixtures
92
+ ├── scripts/ # Build and install helpers
93
+ └── dist/ # npm distribution files
94
+ ```
95
+
96
+ See [AGENTS.md](AGENTS.md) for detailed development guidelines.
97
+
98
+ ## Configuration
99
+
100
+ LearnChain stores configuration in `config/app_config.toml`. Key settings include:
101
+
102
+ - OpenAI API key (required for quiz generation)
103
+ - Default session log paths
104
+ - UI preferences
105
+
106
+ ## Contributing
107
+
108
+ Contributions are welcome! Please:
109
+
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
115
+
116
+ See [AGENTS.md](AGENTS.md) for coding standards and testing guidelines.
117
+
118
+ ## License
119
+
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.
123
+
124
+ ## Acknowledgments
125
+
126
+ - Built with [Ratatui](https://ratatui.rs) - Rust TUI framework
package/dist/.gitkeep ADDED
File without changes
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require('child_process');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ const platform = process.platform;
7
+ const arch = process.arch;
8
+
9
+ // Map Node.js platform/arch to binary names
10
+ const getBinaryName = () => {
11
+ const platformMap = {
12
+ 'darwin': 'darwin',
13
+ 'linux': 'linux',
14
+ 'win32': 'win32'
15
+ };
16
+
17
+ const archMap = {
18
+ 'arm64': 'arm64',
19
+ 'x64': 'x64'
20
+ };
21
+
22
+ const mappedPlatform = platformMap[platform];
23
+ const mappedArch = archMap[arch];
24
+
25
+ if (!mappedPlatform || !mappedArch) {
26
+ console.error(`Unsupported platform: ${platform}-${arch}`);
27
+ console.error('Supported: macOS (arm64/x64), Linux (x64), Windows (x64)');
28
+ process.exit(1);
29
+ }
30
+
31
+ const ext = platform === 'win32' ? '.exe' : '';
32
+ return `learnchain-${mappedPlatform}-${mappedArch}${ext}`;
33
+ };
34
+
35
+ const binaryName = getBinaryName();
36
+ const binPath = path.join(__dirname, binaryName);
37
+
38
+ if (!fs.existsSync(binPath)) {
39
+ console.error(`Binary not found for your platform: ${binaryName}`);
40
+ console.error(`Expected at: ${binPath}`);
41
+ console.error(`\nYour platform: ${platform}-${arch}`);
42
+ console.error('Supported platforms: darwin-arm64, darwin-x64, linux-x64, win32-x64');
43
+ process.exit(1);
44
+ }
45
+
46
+ // Spawn the binary with all arguments
47
+ const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit' });
48
+ child.on('close', (code) => process.exit(code ?? 0));
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
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",
6
+ "author": "Dave Norman <david.norman.w@gmail.com>",
7
+ "bin": {
8
+ "learnchain": "dist/learnchain.js"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/normand1/learnchain"
13
+ },
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"
19
+ },
20
+ "files": [
21
+ "dist/",
22
+ "scripts/install.js",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "keywords": [
27
+ "learnchain",
28
+ "tui",
29
+ "terminal",
30
+ "cli",
31
+ "learning",
32
+ "quiz",
33
+ "ai",
34
+ "codex",
35
+ "claude",
36
+ "education",
37
+ "rust"
38
+ ],
39
+ "engines": {
40
+ "node": ">=16"
41
+ }
42
+ }
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ const { existsSync, chmodSync } = require('fs');
3
+ const path = require('path');
4
+
5
+ const projectRoot = path.join(__dirname, '..');
6
+ const platform = process.platform;
7
+ const arch = process.arch;
8
+
9
+ // Map Node.js platform/arch to our binary naming convention
10
+ const getBinaryName = () => {
11
+ const platformMap = {
12
+ 'darwin': 'darwin',
13
+ 'linux': 'linux',
14
+ 'win32': 'win32'
15
+ };
16
+
17
+ const archMap = {
18
+ 'arm64': 'arm64',
19
+ 'x64': 'x64'
20
+ };
21
+
22
+ const mappedPlatform = platformMap[platform];
23
+ const mappedArch = archMap[arch];
24
+
25
+ if (!mappedPlatform || !mappedArch) {
26
+ console.error(`Unsupported platform: ${platform}-${arch}`);
27
+ console.error('Supported platforms: macOS (arm64/x64), Linux (x64), Windows (x64)');
28
+ process.exit(1);
29
+ }
30
+
31
+ const ext = platform === 'win32' ? '.exe' : '';
32
+ return `learnchain-${mappedPlatform}-${mappedArch}${ext}`;
33
+ };
34
+
35
+ const binaryName = getBinaryName();
36
+ const binaryPath = path.join(projectRoot, 'dist', binaryName);
37
+
38
+ // Verify the pre-compiled binary exists
39
+ if (!existsSync(binaryPath)) {
40
+ console.error(`Pre-compiled binary not found: ${binaryName}`);
41
+ console.error(`Expected at: ${binaryPath}`);
42
+ console.error('\nThis might mean:');
43
+ console.error('1. Your platform is not supported');
44
+ console.error('2. The package was not built correctly');
45
+ console.error(`\nSupported: darwin-arm64, darwin-x64, linux-x64, win32-x64`);
46
+ console.error(`Your platform: ${platform}-${arch}`);
47
+ process.exit(1);
48
+ }
49
+
50
+ // Make binary executable (Unix systems)
51
+ if (platform !== 'win32') {
52
+ try {
53
+ chmodSync(binaryPath, 0o755);
54
+ } catch (err) {
55
+ console.warn(`Warning: Could not make binary executable: ${err.message}`);
56
+ }
57
+ }
58
+
59
+ console.log(`✓ learnchain installed successfully for ${platform}-${arch}`);
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.');