learn_bash_from_session_data 1.0.7 → 1.0.8
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 +141 -18
- package/package.json +1 -1
- package/scripts/html_generator.py +63 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# learn_bash_from_session_data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Turn your Claude Code sessions into personalized bash lessons. This tool extracts every command you've run, enriches them with descriptions and flag breakdowns from a 402-command knowledge base, generates interactive quizzes, and produces a self-contained HTML learning resource.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,37 +8,160 @@ Learn bash from your Claude Code sessions. Extracts commands you've used, catego
|
|
|
8
8
|
npm install -g learn_bash_from_session_data
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
**Requirements:** Node.js >= 14.0.0 and Python >= 3.8
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
#
|
|
16
|
+
# Generate a lesson from your current project's sessions
|
|
15
17
|
learn-bash
|
|
16
18
|
|
|
17
|
-
#
|
|
19
|
+
# Process the last 5 sessions only
|
|
18
20
|
learn-bash -n 5
|
|
19
21
|
|
|
20
|
-
# List available projects
|
|
22
|
+
# List all available Claude Code projects
|
|
21
23
|
learn-bash --list
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The generated HTML opens automatically in your browser.
|
|
27
|
+
|
|
28
|
+
## CLI Reference
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
learn-bash [options]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Flag | Short | Description |
|
|
35
|
+
|------|-------|-------------|
|
|
36
|
+
| `--sessions <count>` | `-n` | Number of recent sessions to process (default: all) |
|
|
37
|
+
| `--file <path>` | `-f` | Process a specific session JSONL file |
|
|
38
|
+
| `--output <path>` | `-o` | Output directory path (default: `./bash-learner-output/`) |
|
|
39
|
+
| `--project <name>` | `-p` | Process sessions from a specific project by name |
|
|
40
|
+
| `--list` | `-l` | List available Claude Code projects with session counts |
|
|
41
|
+
| `--no-open` | | Don't auto-open the generated HTML in browser |
|
|
42
|
+
| `--help` | `-h` | Show help message |
|
|
43
|
+
|
|
44
|
+
### Examples
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Process a specific session file
|
|
48
|
+
learn-bash --file ~/.claude/projects/my-project/abc123.jsonl
|
|
49
|
+
|
|
50
|
+
# Output to a custom location without opening browser
|
|
51
|
+
learn-bash -o ./my-lessons --no-open
|
|
22
52
|
|
|
23
|
-
# Process
|
|
24
|
-
learn-bash --
|
|
53
|
+
# Process sessions from a named project
|
|
54
|
+
learn-bash --project "C--Users-me-my-app"
|
|
25
55
|
|
|
26
|
-
#
|
|
27
|
-
learn-bash
|
|
56
|
+
# Process last 3 sessions, custom output
|
|
57
|
+
learn-bash -n 3 -o ./review
|
|
28
58
|
```
|
|
29
59
|
|
|
30
|
-
##
|
|
60
|
+
## What You Get
|
|
61
|
+
|
|
62
|
+
The tool generates a single interactive HTML file with four sections:
|
|
63
|
+
|
|
64
|
+
### Commands Tab
|
|
65
|
+
Every bash command you used, organized by category with:
|
|
66
|
+
- Syntax-highlighted full command display
|
|
67
|
+
- Flag breakdowns with descriptions (e.g., `-l` = "Long format listing with permissions, size, dates")
|
|
68
|
+
- Subcommand explanations (e.g., `git add` = "Stage file contents for commit")
|
|
69
|
+
- Common usage patterns from the knowledge base
|
|
70
|
+
- Search, sort (by frequency, complexity, category, name), and category filtering
|
|
71
|
+
|
|
72
|
+
### Lessons Tab
|
|
73
|
+
Step-by-step walkthrough of commands grouped by category, with flag details and complexity indicators. Designed for sequential learning.
|
|
74
|
+
|
|
75
|
+
### Quiz Tab
|
|
76
|
+
20 auto-generated questions in four types:
|
|
77
|
+
|
|
78
|
+
| Type | Weight | What It Tests |
|
|
79
|
+
|------|--------|---------------|
|
|
80
|
+
| What does this do? | 40% | Identify a command's purpose from its syntax |
|
|
81
|
+
| Which flag? | 25% | Match a flag to its behavior |
|
|
82
|
+
| Build the command | 20% | Construct the correct command for a task |
|
|
83
|
+
| Spot the difference | 15% | Compare two similar commands |
|
|
84
|
+
|
|
85
|
+
Quizzes are **session-adaptive** (based on commands you actually used), **randomized** (different questions and answer order each run), and use plausible distractors drawn from 402 real commands.
|
|
86
|
+
|
|
87
|
+
### Summary Tab
|
|
88
|
+
Statistics on your session: total commands, category distribution, complexity breakdown, most-used commands.
|
|
89
|
+
|
|
90
|
+
## Knowledge Base
|
|
31
91
|
|
|
32
|
-
-
|
|
33
|
-
- **Categorization**: Groups commands by category (Git, File System, Text Processing, etc.)
|
|
34
|
-
- **Complexity Scoring**: Rates commands from 1-5 based on complexity
|
|
35
|
-
- **Interactive Quizzes**: Test your knowledge with auto-generated quizzes
|
|
36
|
-
- **Self-Contained HTML**: No external dependencies, works offline
|
|
92
|
+
The built-in knowledge base powers descriptions, flag lookups, and quiz generation:
|
|
37
93
|
|
|
38
|
-
|
|
94
|
+
| Metric | Count |
|
|
95
|
+
|--------|-------|
|
|
96
|
+
| Commands documented | 402 |
|
|
97
|
+
| Flag definitions | 1,961 |
|
|
98
|
+
| Common usage patterns | 1,357 |
|
|
99
|
+
| Categories | 11 |
|
|
100
|
+
| Bash operators | 16 |
|
|
101
|
+
| Bash concepts | 6 |
|
|
39
102
|
|
|
40
|
-
|
|
41
|
-
|
|
103
|
+
### Categories
|
|
104
|
+
|
|
105
|
+
File System, Text Processing, Git, Package Management, Process & System, Networking, Permissions, Compression, Search & Navigation, Development, Shell Builtins
|
|
106
|
+
|
|
107
|
+
## How It Works
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
Claude Code session (.jsonl)
|
|
111
|
+
|
|
|
112
|
+
v
|
|
113
|
+
[Parser] --> Extract bash tool_use blocks
|
|
114
|
+
|
|
|
115
|
+
v
|
|
116
|
+
[Extractor] --> Split compound commands (pipes, &&, ;)
|
|
117
|
+
|
|
|
118
|
+
v
|
|
119
|
+
[Analyzer] --> Categorize, score complexity (1-5), count frequency
|
|
120
|
+
|
|
|
121
|
+
v
|
|
122
|
+
[Knowledge Base] --> Enrich with 402 commands, 1961 flags, 1357 patterns
|
|
123
|
+
|
|
|
124
|
+
v
|
|
125
|
+
[Quiz Generator] --> 20 randomized, session-adaptive questions
|
|
126
|
+
|
|
|
127
|
+
v
|
|
128
|
+
[HTML Generator] --> Self-contained interactive HTML (no dependencies)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Session File Location
|
|
132
|
+
|
|
133
|
+
Claude Code stores sessions at:
|
|
134
|
+
|
|
135
|
+
| Platform | Path |
|
|
136
|
+
|----------|------|
|
|
137
|
+
| macOS/Linux | `~/.claude/projects/` |
|
|
138
|
+
| Windows | `%USERPROFILE%\.claude\projects\` |
|
|
139
|
+
| WSL | Auto-detected from `/mnt/c/Users/<name>/.claude/projects/` |
|
|
140
|
+
|
|
141
|
+
Each project directory contains `.jsonl` session files that this tool reads.
|
|
142
|
+
|
|
143
|
+
## Programmatic Usage
|
|
144
|
+
|
|
145
|
+
You can also run the Python pipeline directly:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
python scripts/main.py --sessions 5 --output ./output
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Or import modules in Python:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from scripts.knowledge_base import COMMAND_DB, get_flags_for_command, get_command_info
|
|
155
|
+
from scripts.quiz_generator import generate_quiz_set
|
|
156
|
+
from scripts.analyzer import analyze_commands
|
|
157
|
+
|
|
158
|
+
# Look up a command
|
|
159
|
+
info = get_command_info("grep")
|
|
160
|
+
flags = get_flags_for_command("grep")
|
|
161
|
+
|
|
162
|
+
# Generate quizzes from analyzed commands
|
|
163
|
+
quizzes = generate_quiz_set(analyzed_commands, count=10)
|
|
164
|
+
```
|
|
42
165
|
|
|
43
166
|
## License
|
|
44
167
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "learn_bash_from_session_data",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Learn bash from your Claude Code sessions - extracts commands and generates interactive HTML lessons with 400+ commands, quizzes, and comprehensive coverage",
|
|
5
5
|
"main": "bin/learn-bash.js",
|
|
6
6
|
"bin": {
|
|
@@ -433,7 +433,7 @@ def render_commands_tab(commands: list[dict]) -> str:
|
|
|
433
433
|
<span class="category-badge">{category}</span>
|
|
434
434
|
</div>
|
|
435
435
|
<div class="command-meta">
|
|
436
|
-
<span class="
|
|
436
|
+
<span class="cmd-preview">{description[:60]}{'...' if len(description) > 60 else ''}</span>
|
|
437
437
|
<span class="expand-icon">▼</span>
|
|
438
438
|
</div>
|
|
439
439
|
</div>
|
|
@@ -1358,9 +1358,13 @@ def get_inline_css() -> str:
|
|
|
1358
1358
|
gap: 16px;
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
-
.
|
|
1362
|
-
font-size: 0.
|
|
1361
|
+
.cmd-preview {
|
|
1362
|
+
font-size: 0.8rem;
|
|
1363
1363
|
color: var(--text-secondary);
|
|
1364
|
+
max-width: 400px;
|
|
1365
|
+
overflow: hidden;
|
|
1366
|
+
text-overflow: ellipsis;
|
|
1367
|
+
white-space: nowrap;
|
|
1364
1368
|
}
|
|
1365
1369
|
|
|
1366
1370
|
.expand-icon {
|
|
@@ -2186,20 +2190,31 @@ def generate_html_files(
|
|
|
2186
2190
|
kb_flags = get_flags_for_command(base_cmd)
|
|
2187
2191
|
|
|
2188
2192
|
# Convert flags to expected format WITH descriptions from knowledge base
|
|
2193
|
+
# Filter out non-flag tokens: bare dashes, numeric args (-5, -30), trailing colons
|
|
2194
|
+
import re
|
|
2189
2195
|
raw_flags = cmd.get('flags', [])
|
|
2190
2196
|
formatted_flags = []
|
|
2197
|
+
seen_flags = set()
|
|
2191
2198
|
for f in raw_flags:
|
|
2199
|
+
flag_name = f.get('flag', '') if isinstance(f, dict) else f
|
|
2200
|
+
# Skip bare dash, numeric-only flags (-5, -30), and artifact flags with colons
|
|
2201
|
+
if not flag_name or flag_name == '-' or flag_name.endswith(':'):
|
|
2202
|
+
continue
|
|
2203
|
+
if re.match(r'^-\d+$', flag_name):
|
|
2204
|
+
continue
|
|
2205
|
+
# Deduplicate flags within same command
|
|
2206
|
+
if flag_name in seen_flags:
|
|
2207
|
+
continue
|
|
2208
|
+
seen_flags.add(flag_name)
|
|
2209
|
+
|
|
2192
2210
|
if isinstance(f, dict) and 'flag' in f:
|
|
2193
|
-
# Already formatted - but enrich description if empty
|
|
2194
|
-
flag_name = f.get('flag', '')
|
|
2195
2211
|
flag_desc = f.get('description', '')
|
|
2196
2212
|
if not flag_desc and flag_name in kb_flags:
|
|
2197
2213
|
flag_desc = kb_flags[flag_name]
|
|
2198
2214
|
formatted_flags.append({'flag': flag_name, 'description': flag_desc})
|
|
2199
2215
|
elif isinstance(f, str):
|
|
2200
|
-
# Raw flag string - look up description from knowledge base
|
|
2201
2216
|
flag_desc = kb_flags.get(f, '')
|
|
2202
|
-
# For combined flags like -la,
|
|
2217
|
+
# For combined flags like -la, decompose into individual flags
|
|
2203
2218
|
if not flag_desc and len(f) > 2 and f.startswith('-') and not f.startswith('--'):
|
|
2204
2219
|
char_descs = []
|
|
2205
2220
|
for char in f[1:]:
|
|
@@ -2208,6 +2223,47 @@ def generate_html_files(
|
|
|
2208
2223
|
char_descs.append(f'{single}: {kb_flags[single]}')
|
|
2209
2224
|
if char_descs:
|
|
2210
2225
|
flag_desc = '; '.join(char_descs)
|
|
2226
|
+
# For find-style flags (-name, -type, -path, -maxdepth), add descriptions
|
|
2227
|
+
if not flag_desc:
|
|
2228
|
+
find_flags = {
|
|
2229
|
+
'-name': 'Match files by name pattern',
|
|
2230
|
+
'-type': 'Filter by file type (f=file, d=directory)',
|
|
2231
|
+
'-path': 'Match files by path pattern',
|
|
2232
|
+
'-maxdepth': 'Limit directory recursion depth',
|
|
2233
|
+
'-mindepth': 'Set minimum directory depth',
|
|
2234
|
+
'-exec': 'Execute command on each match',
|
|
2235
|
+
'-not': 'Negate the following expression',
|
|
2236
|
+
'-size': 'Match files by size',
|
|
2237
|
+
'-mtime': 'Match by modification time',
|
|
2238
|
+
'-perm': 'Match by file permissions',
|
|
2239
|
+
'-ls': 'List matched files in ls -l format',
|
|
2240
|
+
'-delete': 'Delete matched files',
|
|
2241
|
+
'-print': 'Print matched file paths',
|
|
2242
|
+
}
|
|
2243
|
+
flag_desc = find_flags.get(f, '')
|
|
2244
|
+
# For common CLI flags without KB entries
|
|
2245
|
+
if not flag_desc:
|
|
2246
|
+
common_flags = {
|
|
2247
|
+
'--help': 'Show help and usage information',
|
|
2248
|
+
'--version': 'Show version number',
|
|
2249
|
+
'--verbose': 'Enable verbose output',
|
|
2250
|
+
'--dry-run': 'Preview changes without executing',
|
|
2251
|
+
'--output': 'Specify output file or directory',
|
|
2252
|
+
'--open': 'Open result in default application',
|
|
2253
|
+
'--stat': 'Show diffstat summary of changes',
|
|
2254
|
+
'--sessions': 'Number of sessions to process',
|
|
2255
|
+
'--title': 'Set custom title',
|
|
2256
|
+
'--no-open': 'Skip auto-opening in browser',
|
|
2257
|
+
'--from': 'Specify input source path',
|
|
2258
|
+
'-s': 'Silent/short output mode',
|
|
2259
|
+
'-n': 'Numeric/count or line number',
|
|
2260
|
+
'-c': 'Execute command string or count',
|
|
2261
|
+
'-g': 'Global scope',
|
|
2262
|
+
'-p': 'Preserve attributes or port',
|
|
2263
|
+
'-o': 'Output file',
|
|
2264
|
+
'-P': 'No dereference (physical path)',
|
|
2265
|
+
}
|
|
2266
|
+
flag_desc = common_flags.get(f, '')
|
|
2211
2267
|
formatted_flags.append({'flag': f, 'description': flag_desc})
|
|
2212
2268
|
|
|
2213
2269
|
# Get educational description from COMMAND_DB if session description is empty/generic
|