cognitune 0.3.0 → 0.3.2

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +183 -42
  3. package/dist/cli.js +8 -7
  4. package/dist/web/assets/Map-DS1CSocK.js +11 -0
  5. package/dist/web/assets/{Practice-DJ_GeEEw.js → Practice-I2bYp2SG.js} +3 -3
  6. package/dist/web/assets/{_baseUniq-Cgcxu-ug.js → _baseUniq-CgG_mifj.js} +1 -1
  7. package/dist/web/assets/{architectureDiagram-UYN6MBPD-F11egvO5.js → architectureDiagram-UYN6MBPD-QZTspen1.js} +1 -1
  8. package/dist/web/assets/{blockDiagram-ZHA2E4KO-DcLwUr6e.js → blockDiagram-ZHA2E4KO-CbhjZ2S8.js} +1 -1
  9. package/dist/web/assets/{c4Diagram-6F5ED5ID-DoK6LsEW.js → c4Diagram-6F5ED5ID-A3b4lbII.js} +1 -1
  10. package/dist/web/assets/channel-BKUyG-l5.js +1 -0
  11. package/dist/web/assets/{chunk-5HRBRIJM-BZZC4mrX.js → chunk-5HRBRIJM-ChWRBpuq.js} +1 -1
  12. package/dist/web/assets/{chunk-7U56Z5CX-CRQL1BaD.js → chunk-7U56Z5CX-Cjcjfrgo.js} +1 -1
  13. package/dist/web/assets/{chunk-ASOPGD6M-MyeXPUAo.js → chunk-ASOPGD6M-Bhu3AOZc.js} +1 -1
  14. package/dist/web/assets/{chunk-KFBOBJHC-ivtJnQTl.js → chunk-KFBOBJHC-BekFNaeo.js} +1 -1
  15. package/dist/web/assets/{chunk-T2TOU4HS-DfaWwXAy.js → chunk-T2TOU4HS-B9G0vLnI.js} +1 -1
  16. package/dist/web/assets/{chunk-TMUBEWPD-1vGEp44G.js → chunk-TMUBEWPD-DSAk9aXZ.js} +1 -1
  17. package/dist/web/assets/classDiagram-LNE6IOMH-zE4bnqcI.js +1 -0
  18. package/dist/web/assets/classDiagram-v2-MQ7JQ4JX-zE4bnqcI.js +1 -0
  19. package/dist/web/assets/clone-BjRjnhL1.js +1 -0
  20. package/dist/web/assets/{dagre-4EVJKHTY-BzJqGMK1.js → dagre-4EVJKHTY-CJiQ7M56.js} +1 -1
  21. package/dist/web/assets/{diagram-QW4FP2JN-DserUmhH.js → diagram-QW4FP2JN-BtE9T_jx.js} +1 -1
  22. package/dist/web/assets/{erDiagram-6RL3IURR-BeMwcZZW.js → erDiagram-6RL3IURR-BURUFe_9.js} +1 -1
  23. package/dist/web/assets/{flowDiagram-7ASYPVHJ-C2Qt1H4b.js → flowDiagram-7ASYPVHJ-CfE3lrqz.js} +1 -1
  24. package/dist/web/assets/{ganttDiagram-NTVNEXSI-DjG6T96W.js → ganttDiagram-NTVNEXSI-D9d9jWBm.js} +1 -1
  25. package/dist/web/assets/{gitGraph-YCYPL57B-C92c8R4j.js → gitGraph-YCYPL57B-CJ1V9XJf.js} +1 -1
  26. package/dist/web/assets/{gitGraphDiagram-NRZ2UAAF-C0OK2-pl.js → gitGraphDiagram-NRZ2UAAF-CqaSLfzI.js} +1 -1
  27. package/dist/web/assets/{graph-jcgmh1Ot.js → graph-B64LQEXc.js} +1 -1
  28. package/dist/web/assets/{index-DM-V8yrZ.js → index-6_jiQxLN.js} +1 -1
  29. package/dist/web/assets/{index-DIV7qBvA.js → index-9QHEA9wu.js} +1 -1
  30. package/dist/web/assets/{index-BtCLkneo.js → index-B-ZU5R2V.js} +1 -1
  31. package/dist/web/assets/{index-BPFm8xBn.js → index-B2zJKCq3.js} +1 -1
  32. package/dist/web/assets/{index-a7yJqPRD.js → index-B52f3nVk.js} +1 -1
  33. package/dist/web/assets/index-BH0BWKEP.js +514 -0
  34. package/dist/web/assets/{index-H4qir-5V.js → index-BluWHHG-.js} +1 -1
  35. package/dist/web/assets/{index-D-9XGv5u.js → index-CUD1JdXZ.js} +1 -1
  36. package/dist/web/assets/{index-DgTHE4KH.js → index-CVnYyVgS.js} +1 -1
  37. package/dist/web/assets/{index-BD8q1ij7.js → index-CtDCXRra.js} +1 -1
  38. package/dist/web/assets/{index-HBtEhFV8.js → index-CujTkxIF.js} +1 -1
  39. package/dist/web/assets/{index-D8PR6AHG.js → index-DGSEVmt_.js} +1 -1
  40. package/dist/web/assets/{index-BTAmHv-d.js → index-DQIDx0VL.js} +1 -1
  41. package/dist/web/assets/{index-D3Zk0Btz.js → index-DYV_a5pR.js} +1 -1
  42. package/dist/web/assets/{index-D5AcpGl_.js → index-DZX_ApSV.js} +1 -1
  43. package/dist/web/assets/index-DeUkCZCv.css +1 -0
  44. package/dist/web/assets/{index-TRTMCU2f.js → index-Dhqj7fLA.js} +1 -1
  45. package/dist/web/assets/{index-B05Rh3LW.js → index-GNn9Y8IP.js} +1 -1
  46. package/dist/web/assets/{index-DJ7YtDlC.js → index-ISt4JlWL.js} +1 -1
  47. package/dist/web/assets/{index-DB9Tltht.js → index-LjQbNYY4.js} +1 -1
  48. package/dist/web/assets/{index-DgVZUoYY.js → index-Z72XDUwe.js} +1 -1
  49. package/dist/web/assets/{index-CfFkiEw9.js → index-fUwh3MJR.js} +1 -1
  50. package/dist/web/assets/{index-BJepU7_w.js → index-fcWIc_lJ.js} +1 -1
  51. package/dist/web/assets/{index-CW1WHdXq.js → index-nRMB7HRL.js} +1 -1
  52. package/dist/web/assets/{infoDiagram-A4XQUW5V-DqkPyvzP.js → infoDiagram-A4XQUW5V-DMcs4U8y.js} +1 -1
  53. package/dist/web/assets/{journeyDiagram-G5WM74LC-CPoGO9lU.js → journeyDiagram-G5WM74LC-CEds3uag.js} +1 -1
  54. package/dist/web/assets/{kanban-definition-QRCXZQQD-DhYcbXpZ.js → kanban-definition-QRCXZQQD-yZwdqxsV.js} +1 -1
  55. package/dist/web/assets/{layout-D3h_RNbG.js → layout-DYrE6rew.js} +1 -1
  56. package/dist/web/assets/layout.worker-Dx5bqvNP.js +1 -0
  57. package/dist/web/assets/{mermaid.core-QonkHgY_.js → mermaid.core-C4isYGdZ.js} +4 -4
  58. package/dist/web/assets/{min-u5yV8FH_.js → min-D7IE57rG.js} +1 -1
  59. package/dist/web/assets/{mindmap-definition-GWI6TPTV-7qne4US6.js → mindmap-definition-GWI6TPTV-BrA9fZLl.js} +1 -1
  60. package/dist/web/assets/{pieDiagram-YF2LJOPJ-CYjuzLxS.js → pieDiagram-YF2LJOPJ-DBLJF-B8.js} +1 -1
  61. package/dist/web/assets/{quadrantDiagram-OS5C2QUG-iNs3hmmI.js → quadrantDiagram-OS5C2QUG-W3e7OODv.js} +1 -1
  62. package/dist/web/assets/{requirementDiagram-MIRIMTAZ-tDYOd2xQ.js → requirementDiagram-MIRIMTAZ-DmouihuU.js} +1 -1
  63. package/dist/web/assets/{sankeyDiagram-Y46BX6SQ-Ce34Wa1G.js → sankeyDiagram-Y46BX6SQ-k_4HmTUK.js} +1 -1
  64. package/dist/web/assets/{sequenceDiagram-G6AWOVSC-i7VCqMq3.js → sequenceDiagram-G6AWOVSC-C4Kq2ABe.js} +1 -1
  65. package/dist/web/assets/{stateDiagram-MAYHULR4-BSREATU6.js → stateDiagram-MAYHULR4-C5a59rCP.js} +1 -1
  66. package/dist/web/assets/stateDiagram-v2-4JROLMXI-CeQk6jDo.js +1 -0
  67. package/dist/web/assets/{timeline-definition-U7ZMHBDA-DgAweJ73.js → timeline-definition-U7ZMHBDA-CtkRQwlM.js} +1 -1
  68. package/dist/web/assets/{xychartDiagram-6QU3TZC5-DxWMJtPc.js → xychartDiagram-6QU3TZC5-KKa8nieo.js} +1 -1
  69. package/dist/web/index.html +2 -2
  70. package/package.json +1 -1
  71. package/dist/web/assets/Map-pFoOaroM.js +0 -1
  72. package/dist/web/assets/channel-cS78OL1L.js +0 -1
  73. package/dist/web/assets/classDiagram-LNE6IOMH-BV-X_A98.js +0 -1
  74. package/dist/web/assets/classDiagram-v2-MQ7JQ4JX-BV-X_A98.js +0 -1
  75. package/dist/web/assets/clone-CX7XQP1C.js +0 -1
  76. package/dist/web/assets/index-Bs71achu.js +0 -509
  77. package/dist/web/assets/index-DajatLhQ.css +0 -1
  78. package/dist/web/assets/stateDiagram-v2-4JROLMXI-CtOZAypx.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2 (2026-11-18)
4
+
5
+ Map:
6
+
7
+ - All nodes are circles: a folder has a ring and its file count, a file is a small dot.
8
+ - A calmer layout: spacing leaves room for each label, and arrowheads keep a fixed size however
9
+ thick the arrow.
10
+ - Text keeps its real size: the map draws 1:1 in pixels, so a small graph is no longer blown up, and
11
+ labels stay readable when a big one is shrunk to fit.
12
+ - Drag a dot to move it; + / - / fit buttons (fit also puts dragged dots back).
13
+ - Click a file to read its code in a pane beside the map; Ctrl/Cmd+click opens it in Explore.
14
+
15
+ ## 0.3.1 (2026-11-18)
16
+
17
+ New:
18
+
19
+ - **Progress rolls up by repo and folder.** At a folder of many repos, each repo is one row with a
20
+ coverage bar; click to go into its folders, then files. A scope bar (breadcrumb with a repo picker)
21
+ narrows the cards, table and heatmap, and search filters the touched files in it. The scope lives
22
+ in the address, so it can be bookmarked. Untouched rows fold into one "show N untouched" line.
23
+ - **Map shows repos and folders, not ~2,000 files.** Nodes are repos, then folders, then files at
24
+ the current scope; a folder of 8 code files or fewer shows its files. Imports between two folders
25
+ are one arrow, thicker for more imports, so a Python package's `__init__.py` no longer looks like a
26
+ hub. Click a folder to go in. The layout runs off the main thread behind a placeholder map, and the
27
+ server keeps the graph until you press Refresh (it used to rebuild every minute).
28
+ - README: a banner, the Read / Prove / Keep loop, and screenshots cropped to be readable.
29
+
30
+ Fixes:
31
+
32
+ - Tutor links dropped the word between two ranges: "lines 41-48 and 58-60" showed as "41-4858-60".
33
+ - The Today page's path card said "Do this stop"; it now names the activity ("Start the lens"),
34
+ like the Paths page.
35
+ - The Library's tab strip stretches to fill its row instead of ending in an empty block.
36
+
3
37
  ## 0.3.0 (2026-11-18)
4
38
 
5
39
  New:
package/README.md CHANGED
@@ -1,63 +1,193 @@
1
- # cognitune
2
-
3
- Understand any codebase, and prove to yourself that you do.
4
-
5
- AI makes code faster to write and easier to not understand. cognitune turns the model around: instead of
6
- writing code for you, it helps you build the model of the code in your own head.
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/banner-dark.svg">
4
+ <img alt="cognitune. Understand any codebase, and prove to yourself that you do." src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/banner-light.svg" width="860">
5
+ </picture>
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/cognitune"><img alt="npm" src="https://img.shields.io/npm/v/cognitune?color=268bd2"></a>
10
+ <img alt="node 20 or newer" src="https://img.shields.io/badge/node-%3E%3D20-859900">
11
+ <img alt="MIT license" src="https://img.shields.io/badge/license-MIT-b58900">
12
+ <img alt="runs locally" src="https://img.shields.io/badge/runs-locally-586e75">
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="#try-it-in-a-minute"><b>Try it</b></a> ·
17
+ <a href="#what-you-do-in-it"><b>What you do in it</b></a> ·
18
+ <a href="#why-it-works"><b>Why it works</b></a> ·
19
+ <a href="SETUP.md"><b>Setup</b></a> ·
20
+ <a href="CHANGELOG.md"><b>Changelog</b></a>
21
+ </p>
22
+
23
+ AI makes code faster to write and easier to not understand.
24
+ **cognitune turns the model around: it does not write code for you. It teaches you the code you have, then checks that you got it.**
25
+
26
+ ## Try it in a minute
7
27
 
8
28
  ```bash
9
- npx cognitune ./my-repo
10
- npx cognitune --demo # a sample repo and canned answers: see every page in a minute, no model needed
29
+ npx cognitune --demo # a sample repo with canned answers. No model, no login.
30
+ npx cognitune ./my-repo # your own code, with the coding CLI you already use
11
31
  ```
12
32
 
13
- Full install/setup guide (model backends, data layout, a shell shortcut): [SETUP.md](SETUP.md).
33
+ - **No new account, no key.** It runs Claude Code, Codex or Copilot with that CLI's own login.
34
+ - **Read-only.** It works from the files you tick, and cognitune never writes to your folders.
35
+ - **Local.** A web app on `127.0.0.1`. Your notes and scores are plain JSON files in `~/.cognitune`.
14
36
 
15
- | | |
16
- |---|---|
17
- | ![Open a folder](assets/screenshots/projects.png) | ![A lens over real code](assets/screenshots/lens.png) |
18
- | ![The import graph](assets/screenshots/map.png) | ![Progress per file](assets/screenshots/progress.png) |
37
+ <p align="center">
38
+ <picture>
39
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/lens-dark.png">
40
+ <img alt="A lens about a retry queue: the idea in one sentence, why it matters, then the words you need first" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/lens.png" width="860">
41
+ </picture>
42
+ <br>
43
+ <sub>A lens: one question, answered about the files you picked. The screenshots are real model output on the bundled 100-line demo repo (Map and Progress show cognitune's own source).</sub>
44
+ </p>
19
45
 
20
- ## What it does
46
+ ## What you do in it
21
47
 
22
- It is built on what makes learning stick: recall beats re-reading, spacing beats cramming, and
23
- producing an answer before you see one beats reading the answer.
48
+ <p align="center">
49
+ <picture>
50
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/loop-dark.svg">
51
+ <img alt="The loop: 1. Read with a question (lens, tutor, walkthrough). 2. Prove it (quiz, teach-back, practice, bug hunt). 3. Keep it (review cards, weak spots, today). What you got wrong comes back." src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/loop-light.svg" width="860">
52
+ </picture>
53
+ </p>
24
54
 
25
- **Read, with a question**
55
+ ### 1. Read with a question
26
56
 
27
57
  | | |
28
58
  |---|---|
29
- | **Lenses** | See code through one question: *Explain*, *Data flow*, *State over time*, *Failure modes*, *Contracts*, *Concepts*, *The change*, *Trace a run* (a debugger without running: line by line with the variables), *History* (why it is like this, from git), or your own. Tick **My take first** to write your own guess before the lens; it opens with where you differ. On a diff, that becomes **Predict first**. A lens shows a banner when its code changes, with one-click refresh. |
30
- | **Walkthrough** | The file in reading order (not file order), one block at a time, with a check question on each block before the next. |
31
- | **Tutor** | A Socratic chat over the files. It answers with a question or a hint first and gives a bit more each turn; ask it to just tell you any time. Opens from any missed quiz question too. |
32
- | **Map** | The import graph (TS/JS with tsconfig aliases, Python), sized by how many files import each one: where to start. |
33
- | **Paths** | An ordered tour of the repo, 6-12 stops, each with the activity that fits. Stops tick off as you do them. |
59
+ | **Lens** | Pick files, pick a question: *Explain*, *Data flow*, *Failure modes*, *Trace a run*, *History*, or your own. You get a lesson where every step shows its own lines of code. Ask a follow-up and the answer joins the same lens. |
60
+ | **Tutor** | A Socratic chat. It gives a nudge first, then a hint, then more. Say "just tell me" any time. Click "line 50" in a reply and the code pane jumps there. |
61
+ | **Walkthrough** | The file in reading order, one block at a time. Each block ends with a question you answer before you go on. |
62
+
63
+ <p align="center">
64
+ <img alt="The tutor answers with a nudge, then a hint. Line numbers in its replies are links into the code pane on the right." src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/tutor.png" width="860">
65
+ <br>
66
+ <sub><b>Tutor.</b> A nudge, then a hint. The blue line numbers jump the code pane.</sub>
67
+ </p>
68
+
69
+ <table>
70
+ <tr>
71
+ <td width="50%"><img alt="A follow-up question answered inside the same lens, with file and line references" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/followup.png"></td>
72
+ <td width="50%"><img alt="A walkthrough block: worked example, a check question, the answer typed and the feedback" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/walk.png"></td>
73
+ </tr>
74
+ <tr>
75
+ <td align="center"><sub><b>Follow-up.</b> Ask more; the answer is added to the lens.</sub></td>
76
+ <td align="center"><sub><b>Walkthrough.</b> Answer the check, then the next block.</sub></td>
77
+ </tr>
78
+ </table>
79
+
80
+ ### 2. Prove it
34
81
 
35
- **Prove it**
82
+ | | |
83
+ |---|---|
84
+ | **Quiz** | Free-text questions about behaviour and reasons, not names. Mark each answer *sure* or *guess*. The feedback names the line you got wrong. A wrong answer you were sure of is flagged first. |
85
+ | **Teach-back** | Explain the code in your own words. Graded 1-5: what is right, what is missing, what is wrong. |
86
+ | **Practice** | The key logic is cut out of a copy of your file. Write it back, with hints. |
87
+ | **Bug hunt** | Bugs are planted in a copy of the file. Find them and say why. |
88
+ | **Changes** | A split diff of two git refs, or of your uncommitted work. Every activity above can run on the diff. Good before you merge code you did not write. |
89
+
90
+ <p align="center">
91
+ <img alt="A graded quiz: score, the question, the answer marked sure, feedback that corrects two line numbers, and a good answer to compare with" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/quiz.png" width="860">
92
+ <br>
93
+ <sub><b>Quiz.</b> The answer was right, the line numbers were off, and the feedback says so.</sub>
94
+ </p>
95
+
96
+ <table>
97
+ <tr>
98
+ <td width="50%"><img alt="Practice: two holes cut out of fail() in queue.ts, the hole's intent on the right, and Check my work" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/practice.png"></td>
99
+ <td width="50%"><img alt="A graded bug hunt: one planted bug found with the reason, one missed, the buggy and real lines side by side" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/hunt.png"></td>
100
+ </tr>
101
+ <tr>
102
+ <td align="center"><sub><b>Practice.</b> Write the missing logic back, then check your work.</sub></td>
103
+ <td align="center"><sub><b>Bug hunt.</b> Found, missed and false alarms, each explained.</sub></td>
104
+ </tr>
105
+ </table>
106
+
107
+ <p align="center">
108
+ <img alt="The Changes page: file list, a split diff of an uncommitted change, and the activities that can run on it" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/changes.png" width="860">
109
+ <br>
110
+ <sub><b>Changes.</b> Read the diff, then lens it, quiz yourself on it or ask the tutor about it.</sub>
111
+ </p>
112
+
113
+ ### 3. Keep it
36
114
 
37
115
  | | |
38
116
  |---|---|
39
- | **Quizzes** | Free-text questions about behaviour and reasons, not names. Mark each answer *sure* or *guess*. Graded with feedback that names the line and a good answer to compare with. |
40
- | **Teach-back** | Explain the code in your own words. Graded 1-5: what you got right, what you missed, what is wrong. |
41
- | **Practice** | The key logic is cut out of a copy of your file (4 levels). Write it back, with hints, then "check my work". |
42
- | **Bug hunt** | Realistic bugs are planted in a copy of the file. Click the lines you suspect and say why; see found, missed and false alarms. |
43
- | **Changes** | Two git refs, or HEAD vs your working tree. Read the diff, then predict, lens or quiz the change itself. |
117
+ | **Weak spots** | A wrong answer is saved as the belief behind it: "you think X, but Y". The next quiz aims at exactly those. A right answer clears one. |
118
+ | **Review cards** | Quiz misses become spaced-repetition cards (FSRS). Each card links back to the quiz or lens it came from. |
119
+ | **Today** | Each project opens on what to do now: cards due, weak spots, files that changed, the next stop on your path. |
120
+ | **Map, Paths, Progress** | See how the repo hangs together, take an ordered tour of it, and see what you have proved and what is fading. |
121
+
122
+ <table>
123
+ <tr>
124
+ <td width="50%"><img alt="Today: a suggested next step, 2 review cards due, two weak spots written as beliefs, and the next learning path stop" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/today.png"></td>
125
+ <td width="50%"><img alt="A review card made from a quiz miss: the question, what you wrote, the answer, and the Again, Hard, Good, Easy buttons" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/review.png"></td>
126
+ </tr>
127
+ <tr>
128
+ <td align="center"><sub><b>Today.</b> What to do now, in about 10 minutes.</sub></td>
129
+ <td align="center"><sub><b>Review.</b> Recall first, then reveal and rate.</sub></td>
130
+ </tr>
131
+ <tr>
132
+ <td width="50%"><img alt="The map: folders sized by their files, thicker arrows for more imports between them" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/map.png"></td>
133
+ <td width="50%"><img alt="Progress: folders rolled up with coverage bars, and cards for understood, fading, stale and seen" src="https://raw.githubusercontent.com/k-pulkit/cognitune/main/assets/screenshots/progress.png"></td>
134
+ </tr>
135
+ <tr>
136
+ <td align="center"><sub><b>Map.</b> Repos and folders, then files. Click a folder to go in.</sub></td>
137
+ <td align="center"><sub><b>Progress.</b> Per repo, folder and file: proved, fading or stale.</sub></td>
138
+ </tr>
139
+ </table>
140
+
141
+ ## Use it when
142
+
143
+ - You joined a team and must find your way in a repo you did not write.
144
+ - An agent wrote the code and you must own it. Open **Changes** and quiz yourself on the diff.
145
+ - You come back to your own code after six months.
146
+ - You review a pull request and want to know what it does, not only that it looks fine.
147
+
148
+ ## Why it works
149
+
150
+ Three findings from learning research decide how every page behaves.
151
+
152
+ | The finding | What cognitune does about it |
153
+ |---|---|
154
+ | **Recall beats re-reading** | Quizzes and teach-back are free text. You write the answer; you do not pick it from a list. |
155
+ | **Spacing beats cramming** | Misses come back as review cards on a schedule. Progress marks a file *fading* when you stop recalling it. |
156
+ | **Answer first, then read** | The tutor hints before it tells. A lens can ask for your own take first. A missed check asks you to try again. |
157
+
158
+ ## Reference
44
159
 
45
- **Keep it**
160
+ <details>
161
+ <summary><b>All features</b></summary>
162
+ <br>
46
163
 
47
164
  | | |
48
165
  |---|---|
166
+ | **Lenses** | See code through one question: *Explain*, *Data flow*, *State over time*, *Failure modes*, *Contracts*, *Concepts*, *The change*, *Trace a run* (a debugger without running: line by line with the variables), *History* (why it is like this, from git), or your own. Tick **My take first** to write your own guess before the lens; it opens with where you differ. On a diff, that becomes **Predict first**. Ask follow-ups at the end; the answers are added to the same lens. A lens shows a banner when its code changes, with one-click refresh. |
167
+ | **Walkthrough** | The file in reading order (not file order), one block at a time, with a check question on each block before the next. Retry a block you missed. |
168
+ | **Tutor** | A Socratic chat over the files. It answers with a question or a hint first and gives a bit more each turn; ask it to just tell you any time. Line references jump the code pane. |
169
+ | **Map** | The import graph (TS/JS with tsconfig aliases, Python) at one scope: repos, then folders, then files. Thicker arrows carry more imports; click a folder to go in. A folder of 8 code files or fewer shows its files. |
170
+ | **Paths** | An ordered tour of the repo, 6-12 stops, each with the activity that fits. Stops tick off as you do them. |
171
+ | **Quizzes** | Free-text questions about behaviour and reasons, not names. Mark each answer *sure* or *guess*. Graded with feedback that names the line and a good answer to compare with. |
172
+ | **Teach-back** | Explain the code in your own words. Graded 1-5: what you got right, what you missed, what is wrong. |
173
+ | **Practice** | The key logic is cut out of a copy of your file (4 levels). Write it back, with hints, then "check my work". |
174
+ | **Bug hunt** | Realistic bugs are planted in a copy of the file. Click the lines you suspect and say why; see found, missed and false alarms. |
175
+ | **Changes** | Two git refs, or HEAD vs your working tree. Read the diff, then predict, lens, quiz, teach back or ask the tutor about the change itself. |
49
176
  | **Review cards** | Spaced repetition (FSRS). Quiz misses become cards on their own; lens concepts and code lines can become cards in one click. |
50
- | **Weak spots** | Wrong answers are saved as the belief behind them ("you think X, but Y"). *Quiz my weak spots* asks new questions aimed at exactly those; a right answer clears one. |
51
- | **Today** | Each project opens on what to do now: due cards, weak spots, files that need a refresh, the next stop on your path, and one suggested 10-minute activity. |
52
- | **Progress** | Per file: *seen*, *understood* (a check passed on the code as it is now), *fading* (no recall for a few weeks), *stale* (the code changed since). Table, or a heatmap of the whole repo. |
53
- | **Library** | Everything made, searchable, plus a glossary built from every lens and your margin notes. Export a lens or quiz as markdown, or a whole project as JSON. |
54
-
55
- `Ctrl/Cmd+K` jumps to any page, file or project, or starts an activity. `?` lists all shortcuts.
177
+ | **Weak spots** | Wrong answers are saved as the belief behind them. Quiz one weak spot or all of them; a right answer clears one; dismiss one the grader got wrong. |
178
+ | **Today** | Due cards, weak spots, files that need a refresh, the next stop on your path, and one suggested 10-minute activity. |
179
+ | **Progress** | Rolled up per repo and folder, then per file: *seen*, *understood* (a check passed on the code as it is now), *fading* (no recall for a few weeks), *stale* (the code changed since). Pick a repo, drill into folders, search; table or heatmap. |
180
+ | **Library** | Everything made, searchable, plus a glossary and your margin notes. Export a lens or quiz as markdown, or a whole project as JSON. |
56
181
 
57
182
  Context is what you pick: tick files in the tree, or add extra folders (docs, notes, design files) to a
58
- project as context. The model reads only what you give it.
183
+ project as context. The model works from what you give it. Long jobs keep running if you leave the page;
184
+ the status bar says when they are ready. <kbd>Ctrl</kbd>/<kbd>Cmd</kbd>+<kbd>K</kbd> jumps anywhere; <kbd>?</kbd> lists shortcuts.
185
+
186
+ </details>
59
187
 
60
- ## Model access
188
+ <details>
189
+ <summary><b>Model access</b>: Claude Code, Codex, Copilot or the Anthropic API</summary>
190
+ <br>
61
191
 
62
192
  cognitune makes one model call per lens, quiz, grade, practice, tutor turn and so on (about 15 s to 2 min).
63
193
  Replies are checked against a schema (one retry with the problems listed), and lens, walkthrough and path
@@ -75,9 +205,16 @@ stores a key**. Pick one in Settings; *Auto* takes the first one it finds, in th
75
205
  Each CLI runs with the project folder as its working directory. Model per provider is optional
76
206
  (empty = the CLI's default). `COGNITUNE_AGENT=fake` gives canned answers, to try the UI without a model.
77
207
 
78
- ## Your files are safe
208
+ Step-by-step setup: [SETUP.md](SETUP.md).
209
+
210
+ </details>
211
+
212
+ <details>
213
+ <summary><b>Your files are safe</b>: local only, read-only, bounded storage</summary>
214
+ <br>
79
215
 
80
216
  - cognitune never writes to your folders. Practice works on a copy.
217
+ - The server binds to `127.0.0.1` only. There is no login: it is a local, one-person tool.
81
218
  - Everything it makes lives in `~/.cognitune` (change with `COGNITUNE_HOME`), as plain JSON files, one
82
219
  per item. Files, not SQLite: the data is small, you can read and back it up, and there is no native
83
220
  module to build.
@@ -104,16 +241,16 @@ sizes and has *Clean up now*):
104
241
 
105
242
  Cleanup runs at start-up and every 6 hours, and only ever inside the cognitune folder.
106
243
 
107
- - The server binds to `127.0.0.1` only. There is no login: it is a local, one-person tool.
244
+ </details>
108
245
 
109
- ## CLI
246
+ <details>
247
+ <summary><b>CLI and development</b></summary>
248
+ <br>
110
249
 
111
250
  ```
112
251
  cognitune [folder] [--port 4711] [--host 127.0.0.1] [--no-open] [--demo]
113
252
  ```
114
253
 
115
- ## Develop
116
-
117
254
  ```bash
118
255
  npm install
119
256
  npm run dev # API on :4711 (tsx watch) + Vite on :5173 with hot reload
@@ -140,6 +277,10 @@ web/src/ React + Vite + Tailwind: pages/, components/, lib/
140
277
  Stack: TypeScript everywhere. Hono on Node 20+, zod, ts-fsrs. React 18, React Router, TanStack Query,
141
278
  Tailwind, Shiki (code), CodeMirror (practice editor), Mermaid (diagrams), d3-force (map).
142
279
 
280
+ </details>
281
+
143
282
  ## License
144
283
 
145
284
  MIT
285
+
286
+ <p align="center"><sub>If cognitune helped you understand something, <a href="https://github.com/k-pulkit/cognitune/issues">tell me what you would change</a>.</sub></p>
package/dist/cli.js CHANGED
@@ -3222,12 +3222,13 @@ function createApi(store2, opts2 = {}) {
3222
3222
  sweep();
3223
3223
  if (opts2.pruneEveryMs) setInterval(sweep, opts2.pruneEveryMs).unref();
3224
3224
  const graphs = /* @__PURE__ */ new Map();
3225
- const graphOf = (p) => {
3226
- const hit = graphs.get(p.id);
3227
- if (hit && Date.now() - hit.at < 6e4) return hit.g;
3228
- const g = new Workspace(p).graph();
3229
- graphs.set(p.id, { at: Date.now(), g });
3230
- return g;
3225
+ const graphOf = (p, refresh = false) => {
3226
+ let hit = graphs.get(p.id);
3227
+ if (!hit || refresh) {
3228
+ hit = { at: Date.now(), g: new Workspace(p).graph() };
3229
+ graphs.set(p.id, hit);
3230
+ }
3231
+ return { ...hit.g, builtAt: new Date(hit.at).toISOString() };
3231
3232
  };
3232
3233
  const hubs = (p) => graphOf(p).nodes.filter((n) => n.fanIn > 0).sort((a, b) => b.fanIn - a.fanIn).map((n) => n.path);
3233
3234
  const offline = () => new Learn(store2, { name: "none", complete: async () => "" });
@@ -3503,7 +3504,7 @@ function createApi(store2, opts2 = {}) {
3503
3504
  if (!store2.get(p.id, "hunts", id)) return fail(c, 404, "bug hunt not found");
3504
3505
  return startJob(c, "huntgrade", p, (l) => l.huntgrade(p, id));
3505
3506
  });
3506
- api.get("/projects/:pid/graph", (c) => c.json(graphOf(project(c))));
3507
+ api.get("/projects/:pid/graph", (c) => c.json(graphOf(project(c), c.req.query("refresh") === "1")));
3507
3508
  api.get("/projects/:pid/glossary", (c) => c.json(glossary(store2, project(c).id)));
3508
3509
  const pathView = (x) => ({ ...x, done: pathDone(store2, x) });
3509
3510
  crud("paths", "paths", pathView);
@@ -0,0 +1,11 @@
1
+ import{c as je,u as J,a as qe,b as Be,d as Xe,e as Ye,f as ae,r as l,g as Ae,j as e,S as Te,h as De,B as Ke,R as Ue,E as ke,M as He,P as Qe,i as Ge,C as Je,G as Ve,F as Ze,k as _e,l as et,m as G}from"./index-BH0BWKEP.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const tt=je("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const st=je("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),ve=8,nt=()=>({new:0,seen:0,understood:0,fading:0,stale:0});function Me(n,u,M,b){var L,P;const f=u.nodes.map(r=>r.path).filter(r=>J(n,r)),m=M.filter(r=>J(n,r.path)),j=r=>{const i=m.find(F=>J(F.path,r));if(i)return{key:i.path,kind:"repo"};const g=r.slice(n.length+1),w=g.indexOf("/");return w<0?{key:r,kind:"file"}:{key:`${n}/${g.slice(0,w)}`,kind:"dir"}},c=new Map;for(const r of f){const{key:i}=j(r);c.set(i,(c.get(i)??0)+1)}if(c.size===1){const[r]=c.keys();if(!f.includes(r)&&r!==n)return Me(r,u,M,b)}const h=new Map;for(const r of f){const i=j(r);h.set(r,i.kind==="dir"&&(c.get(i.key)??0)<=ve?{key:r,kind:"file"}:i)}const S=new Map;for(const[r,{key:i,kind:g}]of h){let w=S.get(i);w||S.set(i,w={id:i,label:i.slice(n.length+1),kind:g,files:0,fanIn:0,fanOut:0,counts:nt()}),w.files++,w.counts[b.get(r)??"new"]++}const R=new Map;let p=0;for(const r of u.edges){const i=(L=h.get(r.from))==null?void 0:L.key,g=(P=h.get(r.to))==null?void 0:P.key;if(!i&&!g)continue;if(!i||!g){p++;continue}if(i===g)continue;const w=`${i}\0${g}`,F=R.get(w)??{from:i,to:g,weight:0};F.weight++,R.set(w,F)}for(const r of R.values())S.get(r.to).fanIn+=r.weight,S.get(r.from).fanOut+=r.weight;return{scope:n,nodes:[...S.values()],edges:[...R.values()],outside:p}}const E={new:"rgb(var(--muted) / 0.45)",seen:"rgb(var(--accent) / 0.45)",understood:"rgb(var(--good))",fading:"rgb(var(--warn) / 0.7)",stale:"rgb(var(--warn))"};function ye(n){const u=n.files-n.counts.new;return n.counts.stale?E.stale:n.counts.fading?E.fading:n.counts.understood*2>=n.files?E.understood:u?E.seen:E.new}const Ne=n=>n.kind==="file"?n.label.split("/").pop():`${n.label}/`,ie=n=>n.kind==="file"?Math.min(16,5+Math.sqrt(n.fanIn)*2.5):Math.min(34,10+Math.sqrt(n.files)*2.2);function rt(n,u){const M=l.useRef(null),b=l.useRef(0),[f,m]=l.useState(null);return l.useEffect(()=>{const j=new Worker(new URL("/assets/layout.worker-Dx5bqvNP.js",import.meta.url),{type:"module"});return M.current=j,j.onmessage=c=>c.data.id===b.current&&m(c.data),()=>j.terminate()},[]),l.useEffect(()=>{if(!M.current||!n.length)return;const j=++b.current;m(null);const c={id:j,nodes:n.map(h=>({id:h.id,r:ie(h),w:Ne(h).length*3.4})),links:u.map(h=>({source:h.from,target:h.to,weight:h.weight}))};M.current.postMessage(c)},[n,u]),(f==null?void 0:f.pos)??null}function be({text:n}){const u=[[-140,-60,22],[-40,-110,14],[70,-70,26],[160,-10,12],[110,80,18],[-10,40,30],[-120,70,16],[30,140,10],[-200,10,10]],M=[[0,5],[0,1],[1,2],[2,3],[2,5],[4,5],[5,6],[4,7],[6,8],[3,4]];return e.jsxs("div",{className:"relative h-full w-full bg-panel",children:[e.jsxs("svg",{className:"h-full w-full animate-pulse",viewBox:"-260 -180 520 360",children:[M.map(([b,f],m)=>e.jsx("line",{x1:u[b][0],y1:u[b][1],x2:u[f][0],y2:u[f][1],stroke:"rgb(var(--muted) / 0.18)",strokeWidth:1.5},m)),u.map(([b,f,m],j)=>e.jsx("rect",{x:b-m,y:f-m,width:m*2,height:m*2,rx:m,fill:"rgb(var(--muted) / 0.14)"},j))]}),e.jsx("div",{className:"absolute inset-0 grid place-items-center",children:e.jsx("div",{className:"rounded-full bg-raised/90 px-4 py-1.5 text-[13px] text-muted shadow-soft",children:n})})]})}function at(){var fe,me;const{project:n,setOpenFile:u,setSelected:M}=qe(),b=Be(),f=Xe(),[m,j]=Ye(),c=n.root.replace(/\/$/,""),h=(m.get("in")??"").replace(/^\/+|\/+$/g,""),S=h?`${c}/${h}`:c,R=s=>j(s&&s!==c?{in:s.slice(c.length+1)}:{}),p=ae({queryKey:["graph",n.id],queryFn:()=>G(`/projects/${n.id}/graph`),staleTime:1/0}),L=ae({queryKey:["progress",n.id],queryFn:()=>G(`/projects/${n.id}/progress`)}),P=ae({queryKey:["repos",n.id,n.contexts],queryFn:()=>G(`/projects/${n.id}/repos`)}),r=l.useMemo(()=>P.data??[],[P.data]),i=l.useMemo(()=>new Map((L.data??[]).map(s=>[s.path,s.level])),[L.data]),g=l.useMemo(()=>new Map((L.data??[]).map(s=>[s.path,s])),[L.data]),w=l.useMemo(()=>{var s;return(((s=p.data)==null?void 0:s.nodes)??[]).map(o=>o.path).filter(o=>J(c,o))},[p.data,c]),F=l.useMemo(()=>r.length>1?Ae(c,w,g,r).filter(s=>s.kind==="repo"):[],[r,c,w,g]),a=l.useMemo(()=>p.data?Me(S,p.data,r,i):null,[p.data,S,r,i]),V=(a==null?void 0:a.scope)??S,W=rt((a==null?void 0:a.nodes)??[],(a==null?void 0:a.edges)??[]),[Y,le]=l.useState(!1),$e=async()=>{le(!0);try{f.setQueryData(["graph",n.id],await G(`/projects/${n.id}/graph?refresh=1`))}finally{le(!1)}},[x,q]=l.useState(null),[Z,A]=l.useState({x:0,y:0,k:1}),z=l.useRef(null),[Se,_]=l.useState({}),ee=l.useRef(!1),[T,ce]=l.useState(null),de=l.useRef(null),[D,Re]=l.useState({w:900,h:600});l.useEffect(()=>{const s=de.current;if(!s)return;const o=new ResizeObserver(([C])=>Re({w:C.contentRect.width,h:C.contentRect.height}));return o.observe(s),()=>o.disconnect()},[W,T]),l.useEffect(()=>{A({x:0,y:0,k:1}),_({}),q(null)},[V]);const Le=s=>{u(s),M([s]),b(`/p/${n.id}/explore`)},ue=(s,o)=>s.kind!=="file"?R(s.id):o!=null&&o.ctrlKey||o!=null&&o.metaKey?Le(s.id):ce(s.id),Fe=e.jsxs(Te,{className:"rounded-none border-x-0 border-t-0",root:c,rootLabel:n.name,scope:V,repos:r,repoRows:F,onScope:R,children:[((fe=p.data)==null?void 0:fe.builtAt)&&e.jsxs("span",{className:"text-[12px] text-muted",children:["imports read ",De(p.data.builtAt)]}),e.jsx(Ke,{size:"sm",variant:"ghost",icon:e.jsx(Ue,{className:Y?"h-3.5 w-3.5 animate-spin":"h-3.5 w-3.5"}),disabled:Y||p.isLoading,onClick:$e,children:"Refresh"})]});if(!p.isLoading&&!((me=p.data)!=null&&me.nodes.length))return e.jsx(ke,{icon:e.jsx(He,{className:"h-6 w-6"}),title:"No imports found",children:"The map reads import lines in TypeScript, JavaScript and Python files. This folder has none that point to other files in it."});const N=(a==null?void 0:a.nodes)??[],I=new Map(N.map(s=>[s.id,s])),te=new Set;if(x)for(const s of(a==null?void 0:a.edges)??[])s.from===x&&te.add(s.to),s.to===x&&te.add(s.from);const he=N.filter(s=>s.fanIn>0).sort((s,o)=>o.fanIn-s.fanIn||o.files-s.files).slice(0,12),ze=new Set((N.length<=40?N:[...N].sort((s,o)=>o.fanIn+o.files-(s.fanIn+s.files)).slice(0,14)).map(s=>s.id)),se=Ne,K=N.filter(s=>s.kind!=="file").length,ne=N.length-K,Ce=((a==null?void 0:a.edges)??[]).reduce((s,o)=>s+o.weight,0);let O;if(p.isLoading||Y)O=e.jsx(be,{text:Y?"Reading imports again…":"Reading imports…"});else if(!N.length)O=e.jsx(ke,{title:"Nothing to show",children:"No code files in here import, or are imported by, another file."});else if(!W)O=e.jsx(be,{text:"Drawing the map…"});else{const s=N.map(t=>W[t.id]??[0,0]),o=s.map(t=>t[0]),C=s.map(t=>t[1]),pe=90,Ee=Math.max(...o)-Math.min(...o)+pe*2,Ie=Math.max(...C)-Math.min(...C)+pe*2,Oe=(Math.max(...o)+Math.min(...o))/2,Pe=(Math.max(...C)+Math.min(...C))/2,B=Math.max(.7,Math.min(1,D.w/Ee,D.h/Ie))*Z.k,xe=D.w/B,ge=D.h/B,U=1/Math.min(B,1),re=t=>A(d=>({...d,k:Math.min(6,Math.max(.2,d.k*t))})),oe=t=>Se[t]??W[t]??[0,0],We=Math.max(1,...((a==null?void 0:a.edges)??[]).map(t=>t.weight));O=e.jsxs("div",{ref:de,className:"relative h-full bg-panel",children:[e.jsxs("svg",{className:"h-full w-full cursor-grab active:cursor-grabbing",viewBox:`${Oe-xe/2+Z.x} ${Pe-ge/2+Z.y} ${xe} ${ge}`,onWheel:t=>re(t.deltaY<0?1.15:1/1.15),onMouseDown:t=>z.current={x:t.clientX,y:t.clientY,node:null,moved:!1},onMouseUp:()=>{var t;ee.current=!!((t=z.current)!=null&&t.moved),z.current=null},onMouseLeave:()=>z.current=null,onMouseMove:t=>{const d=z.current;if(!d)return;const $=(t.clientX-d.x)/B,k=(t.clientY-d.y)/B;if(!(!d.moved&&Math.hypot(t.clientX-d.x,t.clientY-d.y)<3))if(z.current={...d,x:t.clientX,y:t.clientY,moved:!0},d.node){const y=d.node;_(v=>{const[X,H]=v[y]??W[y]??[0,0];return{...v,[y]:[X+$,H+k]}})}else A(y=>({...y,x:y.x-$,y:y.y-k}))},children:[e.jsxs("defs",{children:[e.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"9",markerHeight:"9",markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",children:e.jsx("path",{d:"M0,0 L10,5 L0,10 z",fill:"rgb(var(--muted) / 0.55)"})}),e.jsx("marker",{id:"arrow-on",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"9",markerHeight:"9",markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",children:e.jsx("path",{d:"M0,0 L10,5 L0,10 z",fill:"rgb(var(--accent))"})})]}),((a==null?void 0:a.edges)??[]).map(t=>{const d=I.get(t.from),$=I.get(t.to),[k,y]=oe(d.id),[v,X]=oe($.id),H=Math.hypot(v-k,X-y)||1,we=ie($)+($.kind==="file"?3:6),Q=x===d.id||x===$.id;return e.jsx("line",{x1:k,y1:y,x2:v-(v-k)/H*we,y2:X-(X-y)/H*we,stroke:Q?"rgb(var(--accent))":"rgb(var(--muted) / 0.28)",strokeWidth:(Q?1.2:.8)+Math.log2(1+t.weight/We*15)*.8,markerEnd:Q?"url(#arrow-on)":"url(#arrow)",opacity:x&&!Q?.25:1,children:e.jsx("title",{children:`${se(d)} → ${se($)}: ${t.weight} import${t.weight===1?"":"s"}`})},`${t.from}>${t.to}`)}),N.map(t=>{const[d,$]=oe(t.id),k=ie(t),y=x&&t.id!==x&&!te.has(t.id);return e.jsxs("g",{transform:`translate(${d},${$})`,opacity:y?.25:1,className:"cursor-pointer",onMouseEnter:()=>q(t.id),onMouseLeave:()=>q(null),onMouseDown:v=>{v.stopPropagation(),z.current={x:v.clientX,y:v.clientY,node:t.id,moved:!1}},onClick:v=>{ee.current?ee.current=!1:ue(t,v)},children:[t.id===T&&e.jsx("circle",{r:k+6,fill:"none",stroke:"rgb(var(--accent))",strokeWidth:2}),t.kind==="file"?e.jsx("circle",{r:k,fill:t.counts.new?E.new:ye(t),stroke:"rgb(var(--panel))",strokeWidth:1.5}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{r:k+3,fill:"none",stroke:t.kind==="repo"?"rgb(var(--accent) / 0.75)":"rgb(var(--ink) / 0.2)",strokeWidth:t.kind==="repo"?2.5:1.5}),e.jsx("circle",{r:k,fill:ye(t),stroke:"rgb(var(--panel))",strokeWidth:1.5})]}),t.kind!=="file"&&e.jsx("text",{textAnchor:"middle",dy:"0.35em",fontSize:10*Math.min(U,k/9),className:"fill-ink font-mono",opacity:.7,children:t.files}),(ze.has(t.id)||t.id===x)&&e.jsx("text",{y:-k-6*U,textAnchor:"middle",className:"fill-ink font-mono",fontSize:11.5*U,paintOrder:"stroke",stroke:"rgb(var(--panel))",strokeWidth:3*U,strokeLinejoin:"round",children:se(t)})]},t.id)})]}),e.jsxs("div",{className:"pointer-events-none absolute bottom-3 left-3 flex flex-wrap items-center gap-2 text-[12px] text-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-3 w-3 rounded-full border-2 border-ink/25"}),"folder (number = files)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-muted/50"}),"file"]}),["new","seen","understood","fading","stale"].map(t=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{background:E[t]}}),t==="new"?"not yet":t]},t)),e.jsx("span",{children:"· thicker arrow = more imports · click a folder to go in, a file to read it (Ctrl+click: Explore) · drag a dot to move it"})]}),e.jsxs("div",{className:"absolute right-3 top-3 flex flex-col overflow-hidden rounded-md border border-line bg-panel shadow-soft",children:[e.jsx("button",{className:"grid h-8 w-8 place-items-center text-muted hover:bg-raised hover:text-ink",title:"Zoom in",onClick:()=>re(1.25),children:e.jsx(Qe,{className:"h-4 w-4"})}),e.jsx("button",{className:"grid h-8 w-8 place-items-center border-y border-line text-muted hover:bg-raised hover:text-ink",title:"Zoom out",onClick:()=>re(1/1.25),children:e.jsx(st,{className:"h-4 w-4"})}),e.jsx("button",{className:"grid h-8 w-8 place-items-center text-muted hover:bg-raised hover:text-ink",title:"Fit and put dragged dots back",onClick:()=>{A({x:0,y:0,k:1}),_({})},children:e.jsx(tt,{className:"h-3.5 w-3.5"})})]}),x&&I.get(x)&&e.jsxs("div",{className:"absolute left-3 top-3 rounded-md bg-raised px-2 py-1 font-mono text-xs",children:[I.get(x).label,I.get(x).kind!=="file"&&` · ${I.get(x).files} files, click to open`]})]})}return e.jsxs("div",{className:"flex h-full flex-col",children:[Fe,e.jsx("div",{className:"flex min-h-0 flex-1",children:T?e.jsx(Ge,{id:"map-code",side:"right",initial:520,min:320,max:900,className:"h-full w-full",left:O,right:e.jsx(Je,{file:T,onClose:()=>ce(null)})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-w-0 flex-1",children:O}),e.jsxs("aside",{className:"w-[300px] shrink-0 overflow-auto border-l border-line bg-panel p-4",children:[e.jsx("h1",{className:"text-base font-semibold",children:"Map"}),e.jsx("p",{className:"text-xs text-muted",children:a?e.jsxs(e.Fragment,{children:[K>0&&`${K} ${F.length&&V===c?"repos and folders":"folders"}`,K>0&&ne>0&&", ",ne>0&&`${ne} files`,", ",Ce," imports between them.",a.outside>0&&` ${a.outside} more cross out of this view.`," Folders of ",ve," files or fewer show their files."]}):"Reading the imports in TypeScript, JavaScript and Python files."}),he.length>0&&e.jsx("div",{className:"label mt-4",children:"Most depended on"}),e.jsx("ol",{className:"space-y-1",children:he.map(s=>e.jsx("li",{children:e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-raised",onMouseEnter:()=>q(s.id),onMouseLeave:()=>q(null),onClick:o=>ue(s,o),children:[s.kind==="repo"?e.jsx(Ve,{className:"h-3.5 w-3.5 shrink-0 text-accent"}):s.kind==="dir"?e.jsx(Ze,{className:"h-3.5 w-3.5 shrink-0 text-muted"}):e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0 text-muted"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px]",title:s.label,children:s.label}),e.jsx(et,{children:s.fanIn})]})},s.id))})]})]})})]})}export{at as MapPage};