RayCrafter 0.0.2__tar.gz → 0.0.5__tar.gz

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 (164) hide show
  1. raycrafter-0.0.5/AGENT_WORKFLOW.md +109 -0
  2. {raycrafter-0.0.2 → raycrafter-0.0.5}/CLAUDE.md +76 -19
  3. raycrafter-0.0.5/Changelog.md +49 -0
  4. raycrafter-0.0.5/PKG-INFO +178 -0
  5. raycrafter-0.0.5/README.md +139 -0
  6. raycrafter-0.0.5/RayCrafter.egg-info/PKG-INFO +178 -0
  7. raycrafter-0.0.5/RayCrafter.egg-info/SOURCES.txt +139 -0
  8. {raycrafter-0.0.2 → raycrafter-0.0.5}/RayCrafter.egg-info/entry_points.txt +1 -0
  9. {raycrafter-0.0.2 → raycrafter-0.0.5}/RayCrafter.egg-info/requires.txt +5 -0
  10. raycrafter-0.0.5/RayCrafter.egg-info/scm_file_list.json +199 -0
  11. raycrafter-0.0.5/RayCrafter.egg-info/scm_version.json +8 -0
  12. raycrafter-0.0.5/agent_docs/README.md +136 -0
  13. raycrafter-0.0.5/agent_docs/analyses.md +66 -0
  14. raycrafter-0.0.5/agent_docs/bench.md +190 -0
  15. raycrafter-0.0.5/agent_docs/catalog.md +36 -0
  16. raycrafter-0.0.5/agent_docs/dev.md +82 -0
  17. raycrafter-0.0.5/agent_docs/files.md +81 -0
  18. raycrafter-0.0.5/agent_docs/gui.md +182 -0
  19. raycrafter-0.0.5/agent_docs/optics.md +116 -0
  20. raycrafter-0.0.5/agent_docs/report3d.md +44 -0
  21. raycrafter-0.0.5/agent_docs/scripting.md +63 -0
  22. raycrafter-0.0.5/log.md +9 -0
  23. raycrafter-0.0.5/optiland_fix.md +63 -0
  24. {raycrafter-0.0.2 → raycrafter-0.0.5}/pyproject.toml +13 -6
  25. raycrafter-0.0.5/raycrafter/__init__.py +28 -0
  26. raycrafter-0.0.5/raycrafter/aperture_methods.py +84 -0
  27. raycrafter-0.0.5/raycrafter/api.py +984 -0
  28. raycrafter-0.0.5/raycrafter/assembly_methods.py +146 -0
  29. raycrafter-0.0.5/raycrafter/core/aiming.py +120 -0
  30. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/core/analysis.py +417 -87
  31. raycrafter-0.0.5/raycrafter/core/apertures.py +76 -0
  32. raycrafter-0.0.5/raycrafter/core/assemblies.py +190 -0
  33. raycrafter-0.0.5/raycrafter/core/detector.py +169 -0
  34. raycrafter-0.0.5/raycrafter/core/distortion.py +249 -0
  35. raycrafter-0.0.5/raycrafter/core/examples.py +71 -0
  36. raycrafter-0.0.5/raycrafter/core/field_colours.py +109 -0
  37. raycrafter-0.0.5/raycrafter/core/fields.py +150 -0
  38. raycrafter-0.0.5/raycrafter/core/gap_optimisation.py +521 -0
  39. raycrafter-0.0.5/raycrafter/core/gaps.py +296 -0
  40. raycrafter-0.0.5/raycrafter/core/history.py +156 -0
  41. raycrafter-0.0.5/raycrafter/core/key_planes.py +333 -0
  42. raycrafter-0.0.5/raycrafter/core/model.py +698 -0
  43. raycrafter-0.0.5/raycrafter/core/moving.py +330 -0
  44. raycrafter-0.0.5/raycrafter/core/optic_builder.py +348 -0
  45. raycrafter-0.0.5/raycrafter/core/placement.py +527 -0
  46. raycrafter-0.0.5/raycrafter/core/plossl.py +206 -0
  47. raycrafter-0.0.5/raycrafter/core/plot_geometry.py +329 -0
  48. raycrafter-0.0.5/raycrafter/core/project_file.py +809 -0
  49. raycrafter-0.0.5/raycrafter/core/ray_launch.py +683 -0
  50. raycrafter-0.0.5/raycrafter/core/replacement.py +240 -0
  51. raycrafter-0.0.5/raycrafter/core/scene.py +410 -0
  52. raycrafter-0.0.5/raycrafter/core/state.py +602 -0
  53. raycrafter-0.0.5/raycrafter/core/stop.py +112 -0
  54. raycrafter-0.0.5/raycrafter/core/user_parts.py +184 -0
  55. raycrafter-0.0.5/raycrafter/core/zmx_import.py +788 -0
  56. raycrafter-0.0.5/raycrafter/design_files.py +153 -0
  57. raycrafter-0.0.5/raycrafter/detector_methods.py +122 -0
  58. raycrafter-0.0.5/raycrafter/field_methods.py +221 -0
  59. raycrafter-0.0.5/raycrafter/gap_methods.py +231 -0
  60. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/about_dialog.py +1 -0
  61. raycrafter-0.0.5/raycrafter/gui/agent_link.py +110 -0
  62. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/analysis_panels.py +172 -25
  63. raycrafter-0.0.5/raycrafter/gui/aperture_slider.py +85 -0
  64. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/app.py +10 -1
  65. raycrafter-0.0.5/raycrafter/gui/axis_glyph.py +97 -0
  66. raycrafter-0.0.5/raycrafter/gui/bench_viewer.py +293 -0
  67. raycrafter-0.0.5/raycrafter/gui/context_bar.py +367 -0
  68. raycrafter-0.0.5/raycrafter/gui/current_first_combo.py +72 -0
  69. raycrafter-0.0.5/raycrafter/gui/detector_graphics.py +201 -0
  70. raycrafter-0.0.5/raycrafter/gui/detector_panel.py +104 -0
  71. raycrafter-0.0.5/raycrafter/gui/detector_settings.py +102 -0
  72. raycrafter-0.0.5/raycrafter/gui/field_editor.py +543 -0
  73. raycrafter-0.0.5/raycrafter/gui/file_actions.py +323 -0
  74. raycrafter-0.0.5/raycrafter/gui/gap_dimensions.py +252 -0
  75. raycrafter-0.0.5/raycrafter/gui/gap_optimiser.py +204 -0
  76. raycrafter-0.0.5/raycrafter/gui/hue_strip.py +105 -0
  77. raycrafter-0.0.5/raycrafter/gui/lens_browser.py +621 -0
  78. raycrafter-0.0.5/raycrafter/gui/lens_replacement.py +174 -0
  79. raycrafter-0.0.5/raycrafter/gui/lens_shapes.py +316 -0
  80. raycrafter-0.0.5/raycrafter/gui/main_window.py +979 -0
  81. raycrafter-0.0.5/raycrafter/gui/move_to_menu.py +65 -0
  82. raycrafter-0.0.5/raycrafter/gui/plane_guide.py +237 -0
  83. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/range_slider.py +10 -4
  84. raycrafter-0.0.5/raycrafter/gui/ray_curves.py +59 -0
  85. raycrafter-0.0.5/raycrafter/gui/report_actions.py +88 -0
  86. raycrafter-0.0.5/raycrafter/gui/scaled_slider.py +213 -0
  87. raycrafter-0.0.5/raycrafter/gui/side_readouts.py +112 -0
  88. raycrafter-0.0.5/raycrafter/gui/side_view.py +967 -0
  89. raycrafter-0.0.5/raycrafter/gui/stop_marker.py +56 -0
  90. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/style.py +97 -13
  91. raycrafter-0.0.5/raycrafter/gui/tag_labels.py +98 -0
  92. raycrafter-0.0.5/raycrafter/gui/tool_actions.py +370 -0
  93. raycrafter-0.0.5/raycrafter/gui/tool_icons.py +220 -0
  94. raycrafter-0.0.5/raycrafter/gui/tool_palette.py +134 -0
  95. raycrafter-0.0.5/raycrafter/gui/undo_keys.py +37 -0
  96. raycrafter-0.0.5/raycrafter/gui/view_3d.py +184 -0
  97. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/lenscatalog/catalog.py +26 -0
  98. raycrafter-0.0.5/raycrafter/lenscatalog/selection.py +216 -0
  99. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/lenscatalog/thorlabs.py +26 -0
  100. raycrafter-0.0.5/raycrafter/mcp_server/__init__.py +6 -0
  101. raycrafter-0.0.5/raycrafter/mcp_server/detector_tools.py +72 -0
  102. raycrafter-0.0.5/raycrafter/mcp_server/link.py +195 -0
  103. raycrafter-0.0.5/raycrafter/mcp_server/plane_tools.py +75 -0
  104. raycrafter-0.0.5/raycrafter/mcp_server/server.py +122 -0
  105. raycrafter-0.0.5/raycrafter/mcp_server/stop_tools.py +79 -0
  106. raycrafter-0.0.5/raycrafter/mcp_server/tools.py +988 -0
  107. raycrafter-0.0.5/raycrafter/palette.py +135 -0
  108. raycrafter-0.0.5/raycrafter/plane_methods.py +87 -0
  109. raycrafter-0.0.5/raycrafter/report/__init__.py +5 -0
  110. raycrafter-0.0.5/raycrafter/report/assets/live.js +33 -0
  111. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/report/assets/report.css +17 -1
  112. raycrafter-0.0.5/raycrafter/report/assets/three/LICENSE +21 -0
  113. raycrafter-0.0.5/raycrafter/report/assets/three/OrbitControls.js +1417 -0
  114. raycrafter-0.0.5/raycrafter/report/assets/three/README.md +16 -0
  115. raycrafter-0.0.5/raycrafter/report/assets/three/three.module.min.js +6 -0
  116. raycrafter-0.0.5/raycrafter/report/assets/viewer3d.js +150 -0
  117. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/report/explanations.py +38 -0
  118. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/report/figures.py +224 -28
  119. raycrafter-0.0.5/raycrafter/report/html_report.py +362 -0
  120. raycrafter-0.0.5/raycrafter/report/live_report.py +144 -0
  121. raycrafter-0.0.5/raycrafter/report/live_server.py +156 -0
  122. raycrafter-0.0.5/raycrafter/report/report_process.py +116 -0
  123. raycrafter-0.0.5/raycrafter/report/viewer_3d.py +62 -0
  124. raycrafter-0.0.5/raycrafter/stop_methods.py +101 -0
  125. {raycrafter-0.0.2 → raycrafter-0.0.5}/uv.lock +688 -1
  126. raycrafter-0.0.2/Changelog.md +0 -19
  127. raycrafter-0.0.2/PKG-INFO +0 -76
  128. raycrafter-0.0.2/README.md +0 -41
  129. raycrafter-0.0.2/RayCrafter.egg-info/PKG-INFO +0 -76
  130. raycrafter-0.0.2/RayCrafter.egg-info/SOURCES.txt +0 -53
  131. raycrafter-0.0.2/RayCrafter.egg-info/scm_file_list.json +0 -65
  132. raycrafter-0.0.2/RayCrafter.egg-info/scm_version.json +0 -8
  133. raycrafter-0.0.2/log.md +0 -203
  134. raycrafter-0.0.2/raycrafter/__init__.py +0 -7
  135. raycrafter-0.0.2/raycrafter/core/model.py +0 -493
  136. raycrafter-0.0.2/raycrafter/core/optic_builder.py +0 -188
  137. raycrafter-0.0.2/raycrafter/core/plot_geometry.py +0 -110
  138. raycrafter-0.0.2/raycrafter/core/ray_launch.py +0 -121
  139. raycrafter-0.0.2/raycrafter/core/state.py +0 -174
  140. raycrafter-0.0.2/raycrafter/core/zmx_import.py +0 -384
  141. raycrafter-0.0.2/raycrafter/gui/field_editor.py +0 -337
  142. raycrafter-0.0.2/raycrafter/gui/lens_picker.py +0 -377
  143. raycrafter-0.0.2/raycrafter/gui/main_window.py +0 -663
  144. raycrafter-0.0.2/raycrafter/gui/side_view.py +0 -752
  145. raycrafter-0.0.2/raycrafter/lenscatalog/selection.py +0 -132
  146. raycrafter-0.0.2/raycrafter/palette.py +0 -66
  147. raycrafter-0.0.2/raycrafter/report/__init__.py +0 -5
  148. raycrafter-0.0.2/raycrafter/report/html_report.py +0 -226
  149. {raycrafter-0.0.2 → raycrafter-0.0.5}/.github/workflows/test_and_deploy.yml +0 -0
  150. {raycrafter-0.0.2 → raycrafter-0.0.5}/.gitignore +0 -0
  151. {raycrafter-0.0.2 → raycrafter-0.0.5}/LICENSE +0 -0
  152. {raycrafter-0.0.2 → raycrafter-0.0.5}/MANIFEST.in +0 -0
  153. {raycrafter-0.0.2 → raycrafter-0.0.5}/RayCrafter.egg-info/dependency_links.txt +0 -0
  154. {raycrafter-0.0.2 → raycrafter-0.0.5}/RayCrafter.egg-info/top_level.txt +0 -0
  155. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/__main__.py +0 -0
  156. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/core/__init__.py +0 -0
  157. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/core/prescription.py +0 -0
  158. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/__init__.py +0 -0
  159. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/gui/compile_notice.py +0 -0
  160. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/lenscatalog/__init__.py +0 -0
  161. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/lenscatalog/data/thorlabs.json.gz +0 -0
  162. {raycrafter-0.0.2 → raycrafter-0.0.5}/raycrafter/report/assets/report.js +0 -0
  163. {raycrafter-0.0.2 → raycrafter-0.0.5}/scripts/make_thorlabs_catalog.py +0 -0
  164. {raycrafter-0.0.2 → raycrafter-0.0.5}/setup.cfg +0 -0
@@ -0,0 +1,109 @@
1
+ # How coding agents work on RayCrafter
2
+
3
+ Most of RayCrafter's code is written by AI coding agents (such as Claude Code), working with the
4
+ project's developers. This page explains, for people, the notes the agents keep and how several
5
+ agents can work at the same time. The rules the agents themselves follow are in
6
+ [CLAUDE.md](CLAUDE.md), under "Agent workflow".
7
+
8
+
9
+ ## The problem
10
+
11
+ Each agent session starts with no memory of earlier ones. Without help, a new session spends
12
+ much of its time (and its limited context) re-reading the code to work out how it fits
13
+ together. Several agents working at once each pay that cost again, and can make clashing
14
+ changes.
15
+
16
+
17
+ ## The agent notes: `agent_docs/`
18
+
19
+ [`agent_docs/`](agent_docs/README.md) holds short notes for agents, one file per topic:
20
+
21
+ | File | Topic |
22
+ |---|---|
23
+ | `bench.md` | the bench state and every edit to it (placing, moving, gaps, assemblies, apertures, detector, undo) |
24
+ | `optics.md` | building the Optiland system, launching and tracing rays, fields |
25
+ | `analyses.md` | spot, through-focus, MTF, ray fan, field curvature, distortion, light on the detector |
26
+ | `catalog.md` | lens catalogues and user parts |
27
+ | `files.md` | project files and Zemax import and export |
28
+ | `gui.md` | the window |
29
+ | `report3d.md` | the HTML report, the live report and the 3D scene |
30
+ | `scripting.md` | the Python `Bench`, the MCP server and the link to the open window |
31
+ | `dev.md` | tooling, tests, CI, branches, releases |
32
+
33
+ Each file says which modules and tests the topic owns, gives a one-line map of each module, says
34
+ how to extend it and what to watch out for, and ends with the topic's **decision log**: the
35
+ significant decisions and why they were made. Every module belongs to exactly one topic; a test
36
+ (`tests/test_unit/test_agent_docs.py`) fails if a new module is not added to the notes.
37
+
38
+ `agent_docs/README.md` is read first. It lists the topics, which ones to read for common tasks,
39
+ a checklist for changes that cross topics, the conventions all topics share (units, numbering),
40
+ and the files most often changed.
41
+
42
+ The notes are written tersely, with abbreviations defined in the README (e.g. `OM` for
43
+ `OpticalModel`, dates as YYMMDD), because agents read them on every task. They are meant to be
44
+ read through an agent; they are not documentation for users. The detail stays in the code's
45
+ docstrings, which the notes point to rather than repeat. The decision log used to be a single
46
+ `log.md` in plain prose; that version is kept in git (`git show 3722753:log.md`).
47
+
48
+
49
+ ## What an agent does for each task
50
+
51
+ 1. Reads `agent_docs/README.md` and only the topic files the task needs.
52
+ 2. Proposes the change and the files it expects to touch.
53
+ 3. Reads the code it needs. Where the notes and the code disagree, the code is right and the
54
+ notes are fixed.
55
+ 4. Makes the change and runs the tests.
56
+ 5. Updates the topic's notes in the same commit, and adds to its log if a decision was made
57
+ (decisions Rob has not agreed to are asked about first).
58
+ 6. For substantial work, leaves a short handoff as a comment on the GitHub issue: what was done,
59
+ what was tried and rejected, what is left.
60
+
61
+
62
+ ## Working with several agents at once
63
+
64
+ Each agent needs its own copy of the files, or the agents overwrite each other's edits. Git
65
+ provides this with **worktrees**: extra folders, each with its own branch checked out, all
66
+ sharing one repository. So each parallel job is one worktree on one branch.
67
+
68
+ - Work in parallel only on topics that do not overlap. The files that most changes touch
69
+ (`main_window.py`, `model.py`, `side_view.py`, `mcp_server/tools.py`, `state.py`) are listed in
70
+ `agent_docs/README.md`; two jobs that both need to change one of them heavily, or that change
71
+ `OpticalState`, should be agreed first or done one after the other.
72
+ - **Keep worktrees out of Dropbox**, so that Dropbox does not sync several checkouts to every
73
+ machine. Claude Code's own worktree option may put them inside the repository folder, so make
74
+ them by hand.
75
+ - **Give each worktree its own virtual environment.** The editable install in a venv points at
76
+ one checkout, so a shared venv would test another worktree's code.
77
+
78
+ Starting a job (here called `fields-ui`), from the main checkout:
79
+
80
+ ```
81
+ git checkout dev && git pull
82
+ git worktree add ~/worktrees/raycrafter-fields-ui -b fields-ui dev
83
+ cd ~/worktrees/raycrafter-fields-ui
84
+ export UV_PROJECT_ENVIRONMENT=~/uv_venvs/raycrafter_fields-ui
85
+ uv sync --extra dev
86
+ claude
87
+ ```
88
+
89
+ Finishing it, back in the main checkout:
90
+
91
+ ```
92
+ git checkout dev
93
+ git merge fields-ui # then run the full tests on the combined code
94
+ git worktree remove ~/worktrees/raycrafter-fields-ui
95
+ git branch -d fields-ui
96
+ rm -rf ~/uv_venvs/raycrafter_fields-ui
97
+ ```
98
+
99
+ Someone (Rob, or one agent asked to do so) acts as coordinator: hands out the jobs, agrees any
100
+ change to shared interfaces before the work starts, merges the branches into `dev` one at a
101
+ time, and runs the tests after each merge.
102
+
103
+
104
+ ## Keeping or restarting a session
105
+
106
+ A session builds up useful understanding, so there is no need to restart one each time a piece
107
+ of work is done. Keep it for follow-up fixes, tests and closely related work in the same topic.
108
+ Start a fresh session for a different topic, or when a long session starts confusing old and
109
+ current code; ask for a handoff on the issue first, so nothing is lost.
@@ -9,7 +9,7 @@ little or no AI. If something would confuse a careful human reader, it is wrong.
9
9
  # Architecture rules
10
10
 
11
11
  - **`raycrafter.core` never imports Qt.** It holds the optical model and the analyses. The GUI,
12
- the HTML report, scripts and (later) an MCP server for AI agents all use the same core API.
12
+ the HTML report, scripts and the MCP server for AI agents all use the same core API.
13
13
  - **Model/view.** The GUI (`raycrafter.gui`) displays the core model and turns user actions into
14
14
  calls on it. It holds no optical state of its own beyond what it needs to draw.
15
15
  - **Object-oriented, modular.** One clear responsibility per module. Subpackages must be usable
@@ -20,12 +20,19 @@ little or no AI. If something would confuse a careful human reader, it is wrong.
20
20
  else goes on the slow path (after changes settle) or runs only once nothing is being
21
21
  dragged, as the f-number does (`MainWindow.is_dragging`). Measure what you add to the fast
22
22
  path; the side view shows the trace and draw times.
23
+ - **The model is a thin front.** `OpticalModel` (`core/model.py`) holds only what needs more
24
+ than the bench state: the catalogue, the user parts folder, undo and files. Any editing rule
25
+ or calculation goes in a topic module of `core` as a function of an `OpticalState`
26
+ (`placement`, `moving`, `gaps`, `assemblies`, `replacement`, `gap_optimisation`, ...), or in
27
+ a new module. The model method is then a one-line wrapper whose docstring says what it does
28
+ in one line and names that function; the details are documented there, not repeated.
23
29
  - **File size.** Aim for files under about 1000 lines. This is a soft limit: if a file has to be
24
- bigger, say why in `log.md`.
30
+ bigger, say why in its topic's log in `agent_docs/`.
25
31
  - **Optiland.** It is pinned to a tested minor version in `pyproject.toml`. Any workaround for an
26
32
  Optiland bug goes in one clearly marked place, with a comment that links to the upstream issue.
27
33
  Delete the workaround once the fix is released. When new versions of Optiland are released:
28
- test them and upgrade as soon as possible.
34
+ test them and upgrade as soon as possible. Every workaround, and every upstream fix we are
35
+ waiting for, is recorded in `optiland_fix.md` (see Releases for the check at each release).
29
36
 
30
37
  Package layout:
31
38
 
@@ -35,6 +42,8 @@ raycrafter/
35
42
  lenscatalog/ lens catalogues (JSON data plus loaders)
36
43
  report/ HTML report (matplotlib figures)
37
44
  gui/ PyQt6 + pyqtgraph application
45
+ mcp_server/ tools for AI agents (MCP), and the link to the open window
46
+ api.py the Python scripting interface, ``Bench`` (with the ``*_methods.py`` mixins)
38
47
  palette.py colours shared by the GUI and the report
39
48
  ```
40
49
 
@@ -54,6 +63,16 @@ raycrafter/
54
63
  - Once a feature is complete, remove any dead code.
55
64
 
56
65
 
66
+ # GUI conventions
67
+
68
+ - **Every drop-down**, anywhere in RayCrafter, opens with the currently selected entry at the
69
+ top, as the "Beams" drop-down of the field editor does. Otherwise the focus moves
70
+ distractingly when the user returns to the drop-down. Always make one with
71
+ `CurrentFirstComboBox` (`gui/current_first_combo.py`), never a plain `QComboBox` (a test
72
+ checks this), and read or set its choice by data (`currentData`, `findData`), as its rows
73
+ change order.
74
+
75
+
57
76
  # Tests
58
77
 
59
78
  - Run them with `uv run pytest`. Tests live in `tests/test_unit` (fast, no display) and
@@ -95,11 +114,29 @@ raycrafter/
95
114
 
96
115
  ## Releases
97
116
 
117
+ - **Optiland check, before the code review.** When a release is being prepared, first check
118
+ whether Optiland has a new release (`gh release list --repo optiland/optiland`). If it has:
119
+ 1. Switch to it (update the pin in `pyproject.toml` and `uv.lock`).
120
+ 2. Go through `optiland_fix.md` and remove every workaround the new release makes
121
+ unnecessary. Move its entry to "Retired".
122
+ 3. Re-patch anything that is still broken, and make sure each remaining workaround is in
123
+ `optiland_fix.md` with its upstream issue link (file an issue if there is none; ask Rob
124
+ before filing, and search existing issues first).
125
+ 4. Run the full tests and pre-commit hooks.
126
+ Only then start the adversarial code review below. Update the "last checked" date in
127
+ `optiland_fix.md` even when there is no new release.
98
128
  - When it is time for a new release, you will first conduct an adversarial code review of
99
- work down between now and the last release. The main task of the review will be to find
100
- bugs that may have been introduced. However, you should also verify that the changes made
101
- are in keeping with the design plan of the software. Once any fixes have been applied
102
- after the review ends, it is OK to increment the version and deploy the new release.
129
+ work down between now and the last release. The main tasks of the review will be to find
130
+ bugs that may have been introduced and check that there are no mistakes in the optical
131
+ principles underlying the work. You should also verify that the changes made
132
+ are in keeping with the design plan of the software. Before release you should ensure
133
+ that the agent_docs are all up to date and in sync with the code. Note that agents doing
134
+ the initial work may be running more simple models than that doing the adversarial review
135
+ and merge. Therefore at this point better ways of solving a problem may come to light.
136
+ It is acceptable for hunt for this and implement them at this stage. Ask the human
137
+ reviewer as needed when doing this. We want the best version of the approach going into
138
+ the release. Once any fixes have been applied after the review ends, it is OK to
139
+ increment the version and deploy the new release to PyPI.
103
140
  - Versions come from git tags via setuptools-scm, using semantic versioning. Pushing a
104
141
  `vX.Y.Z` tag publishes to PyPI. Always verify your proposed new version number with the
105
142
  human managing the project.
@@ -119,24 +156,44 @@ raycrafter/
119
156
  - `rm` and `mv` are aliased to interactive versions on Rob's machines, so use `rm -f` / `mv -f`.
120
157
 
121
158
 
122
- # Decision log (`log.md`)
159
+ # Agent workflow and `agent_docs/`
160
+
161
+ `agent_docs/` is a map of the code and its decision log, split into topics (bench, gui, optics,
162
+ ...), so an agent can start work without reading the whole code base. It is written tersely,
163
+ for agents only; `agent_docs/README.md` defines its abbreviations. `AGENT_WORKFLOW.md` explains
164
+ the scheme to humans. For every task:
165
+
166
+ 1. **Orient.** Read `agent_docs/README.md`, then only the topic files its "Typical tasks" table
167
+ names for the task. Do not read other topics' files or logs unless the task touches them.
168
+ 2. **Propose.** Say what you will change and which files you expect to touch (one line is
169
+ enough for a small fix). Changing `OpticalState`, a "hot file" listed in the README, or more
170
+ than one topic needs Rob's agreement before parallel work on those topics.
171
+ 3. **Read the code you need.** The code is the truth: if a topic file disagrees with it, fix
172
+ the topic file.
173
+ 4. **Change and test** as usual (tests, pre-commit).
174
+ 5. **Update the docs in the same commit.** Update the topic's map, "How to add" and "Rules"
175
+ sections if they changed. A new module goes in exactly one topic, in the README's table and
176
+ that topic's map (`tests/test_unit/test_agent_docs.py` checks this). If a decision was made,
177
+ append an entry to the topic's log.
178
+ 6. **Hand off.** At the end of substantial work, post a short comment on the issue: what was
179
+ done, what was tried and rejected (and why), what is left, and the test results.
123
180
 
124
- `log.md` records significant decisions and why they were made, so the history of the project
125
- can be traced later (e.g. for a paper). Keep it short so it stays cheap to search.
181
+ The decision log records significant decisions and why they were made, so the history of the
182
+ project can be traced later (e.g. for a paper).
126
183
 
127
- - **Before starting work**, search the log for the topic, e.g.
128
- `grep -n -i -A6 "catalog" log.md`. Read the matching entries only, not the whole file.
129
184
  - **Add an entry** for a decision someone might later ask "why?" about: architecture,
130
185
  dependencies, tooling, physics approximations, Optiland workarounds, or something tried and
131
186
  abandoned. Do not log routine changes or bug fixes; git and the issues record those.
132
- - **Append only.** Add new entries at the end and never rewrite old ones. If a decision is
133
- reversed, add a new entry that says which entry it supersedes.
134
- - **Format.** Each entry is at most about 8 lines:
187
+ - **Append only.** Add new entries at the end of the topic's log and never rewrite old ones. If a
188
+ decision is reversed, add a new entry whose `X:` line names the entry it supersedes.
189
+ - **Format**: at most about 5 lines, dates YYMMDD, terse (see `agent_docs/README.md`):
135
190
 
136
191
  ```
137
- ## YYYY-MM-DD: Short title
138
- **Decision:** what was decided.
139
- **Why:** the reason, including alternatives rejected.
140
- **Supersedes:** (optional) the date and title of the earlier entry.
192
+ ### YYMMDD Short title (#issue)
193
+ D: what was decided.
194
+ W: why, including alternatives rejected.
195
+ X: (optional) the date and title of the entry it supersedes.
141
196
  ```
142
197
  - Ask Rob before logging a decision that he has not made or agreed to.
198
+ - **Parallel agents** each work in their own git worktree on their own feature branch from
199
+ `dev`, outside Dropbox, with their own venv (see `AGENT_WORKFLOW.md`).
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ Each release also has a release message on
4
+ [GitHub](https://github.com/raycrafter-optical-design/raycrafter/releases).
5
+
6
+
7
+ ## [0.0.5](https://github.com/raycrafter-optical-design/raycrafter/releases/tag/v0.0.5) (2026-11-29)
8
+
9
+ - New layout: a tool palette and a context bar, with the lens browser and field editor in the main window [#70](https://github.com/raycrafter-optical-design/raycrafter/issues/70).
10
+ - Variable apertures (irises), which can sit inside locked gaps and assemblies [#71](https://github.com/raycrafter-optical-design/raycrafter/issues/71).
11
+ - Choose the aperture stop, and let the fields fill it, with every ray aimed through it [#83](https://github.com/raycrafter-optical-design/raycrafter/issues/83).
12
+ - A detector on the image plane, and the share of each field's light that lands on it [#91](https://github.com/raycrafter-optical-design/raycrafter/issues/91).
13
+ - Focal points of lenses and assemblies are marked; elements snap to them or move there exactly [#77](https://github.com/raycrafter-optical-design/raycrafter/issues/77), [#107](https://github.com/raycrafter-optical-design/raycrafter/issues/107).
14
+ - Finite objects (object points), with grid distortion [#29](https://github.com/raycrafter-optical-design/raycrafter/issues/29), [#30](https://github.com/raycrafter-optical-design/raycrafter/issues/30).
15
+ - Field editor with sliders and colour rules; choose the number of rays drawn [#86](https://github.com/raycrafter-optical-design/raycrafter/issues/86), [#84](https://github.com/raycrafter-optical-design/raycrafter/issues/84).
16
+ - Optimise a gap to collimate or focus; replace a lens with one of the same focal length; Plossl pairs [#38](https://github.com/raycrafter-optical-design/raycrafter/issues/38), [#56](https://github.com/raycrafter-optical-design/raycrafter/issues/56), [#63](https://github.com/raycrafter-optical-design/raycrafter/issues/63), [#66](https://github.com/raycrafter-optical-design/raycrafter/issues/66).
17
+ - A 3D view, and a web report that updates live [#51](https://github.com/raycrafter-optical-design/raycrafter/issues/51), [#52](https://github.com/raycrafter-optical-design/raycrafter/issues/52), [#68](https://github.com/raycrafter-optical-design/raycrafter/issues/68).
18
+ - Elements may come within 1 mm of the start of the axis; plane labels stay readable [#80](https://github.com/raycrafter-optical-design/raycrafter/issues/80).
19
+ - Known problems: ZMX files do not carry the detector or the stop [#105](https://github.com/raycrafter-optical-design/raycrafter/issues/105), [#106](https://github.com/raycrafter-optical-design/raycrafter/issues/106).
20
+
21
+
22
+ ## [0.0.4](https://github.com/raycrafter-optical-design/raycrafter/releases/tag/v0.0.4) (2026-11-26)
23
+
24
+ Version 0.0.3 was skipped.
25
+
26
+ - Project files (`.raycrafter`) keep the whole design, and the Zemax file it was imported from ([#40](https://github.com/raycrafter-optical-design/raycrafter/issues/40)).
27
+ - Undo and redo ([#37](https://github.com/raycrafter-optical-design/raycrafter/issues/37)).
28
+ - Gaps between lenses are shown, can be typed and locked ([#35](https://github.com/raycrafter-optical-design/raycrafter/issues/35), [#36](https://github.com/raycrafter-optical-design/raycrafter/issues/36)).
29
+ - Assemblies: group lenses, flip them as one, save them as user parts. Plossl pairs are assemblies ([#43](https://github.com/raycrafter-optical-design/raycrafter/issues/43)).
30
+ - Fields are defined at a source plane with its own position ([#41](https://github.com/raycrafter-optical-design/raycrafter/issues/41)).
31
+ - Python scripting API, `raycrafter.Bench` ([#31](https://github.com/raycrafter-optical-design/raycrafter/issues/31)).
32
+ - MCP server for AI agents, which can also drive the open window ([#26](https://github.com/raycrafter-optical-design/raycrafter/issues/26), [#28](https://github.com/raycrafter-optical-design/raycrafter/issues/28)).
33
+ - Bench viewer and part metadata ([#34](https://github.com/raycrafter-optical-design/raycrafter/issues/34), [#42](https://github.com/raycrafter-optical-design/raycrafter/issues/42)).
34
+ - Zemax import aims fields through the stop and reads apertures properly; the side view fits the design ([#17](https://github.com/raycrafter-optical-design/raycrafter/issues/17)–[#21](https://github.com/raycrafter-optical-design/raycrafter/issues/21)).
35
+
36
+
37
+ ## [0.0.2](https://github.com/raycrafter-optical-design/raycrafter/releases/tag/v0.0.2) (2026-11-24)
38
+
39
+ - Lens picker dialog and the full Thorlabs catalogue ([#1](https://github.com/raycrafter-optical-design/raycrafter/issues/1)).
40
+ - Rays outside a lens's clear aperture are blocked; slow analyses wait until a drag ends ([#3](https://github.com/raycrafter-optical-design/raycrafter/issues/3)).
41
+ - Paraxial (ideal thin) lenses ([#6](https://github.com/raycrafter-optical-design/raycrafter/issues/6)).
42
+ - Several fields (beams), edited live in a field window ([#7](https://github.com/raycrafter-optical-design/raycrafter/issues/7)).
43
+ - File menu: new, save and load Zemax `.zmx` files ([#8](https://github.com/raycrafter-optical-design/raycrafter/issues/8)).
44
+ - Requires Python 3.12+ and PyQt6 6.8+.
45
+
46
+
47
+ ## 0.0.1 (2026-11-23)
48
+
49
+ First preview release.
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.4
2
+ Name: RayCrafter
3
+ Version: 0.0.5
4
+ Summary: Raytracing GUI for simple optical systems using off-the-shelf lenses and Optiland
5
+ Author-email: Rob Campbell <git@raacampbell.com>
6
+ License-Expression: MIT
7
+ Project-URL: Source Code, https://github.com/raycrafter-optical-design/raycrafter
8
+ Project-URL: Bug Tracker, https://github.com/raycrafter-optical-design/raycrafter/issues
9
+ Classifier: Development Status :: 2 - Pre-Alpha
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Requires-Python: >=3.12.0
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: optiland<0.7,>=0.6.3
20
+ Requires-Dist: numpy
21
+ Requires-Dist: scipy
22
+ Requires-Dist: matplotlib
23
+ Requires-Dist: PyQt6>=6.8
24
+ Requires-Dist: pyqtgraph>=0.14
25
+ Requires-Dist: pyopengl>=3.1.7
26
+ Provides-Extra: mcp
27
+ Requires-Dist: mcp<2.4,>=2.3; extra == "mcp"
28
+ Provides-Extra: dev
29
+ Requires-Dist: mcp<2.4,>=2.3; extra == "dev"
30
+ Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: pytest-cov; extra == "dev"
32
+ Requires-Dist: coverage; extra == "dev"
33
+ Requires-Dist: tox; extra == "dev"
34
+ Requires-Dist: mypy; extra == "dev"
35
+ Requires-Dist: pre-commit; extra == "dev"
36
+ Requires-Dist: ruff; extra == "dev"
37
+ Requires-Dist: setuptools-scm; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # RayCrafter
41
+
42
+ [![Python Version](https://img.shields.io/pypi/pyversions/raycrafter.svg)](https://pypi.org/project/raycrafter)
43
+ [![PyPI Version](https://img.shields.io/pypi/v/raycrafter.svg)](https://pypi.org/project/raycrafter)
44
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
45
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/raycrafter-optical-design/raycrafter/test_and_deploy.yml?branch=main&label=CI)](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
46
+ [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
47
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
48
+ [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
49
+
50
+ RayCrafter is an early proof of principle for a lens-level optical design tool. You place
51
+ off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
52
+ through-focus curve, MTF, ray fan, field curvature and distortion update as you go. The ray
53
+ tracing is done by [Optiland](https://github.com/optiland/optiland).
54
+
55
+ - **Lenses:** the Thorlabs spherical lenses, achromats, air-spaced doublets, triplets and
56
+ matched pairs, plus ideal (paraxial) lenses.
57
+ - **Layout:** type the gaps between lenses and lock them; group lenses into assemblies (such
58
+ as Plossl pairs) and save them as your own parts.
59
+ - **Beams:** any number, each with its own width, angle, vergence, offset and wavelength.
60
+ - **3D view:** View > Show 3D View shows the lenses and rays in a window you can rotate.
61
+ - **Files:** save designs as RayCrafter project files, import and export Zemax `.zmx` files,
62
+ and open a report with a 3D view in your browser, which updates as you change the design
63
+ and can be saved as one file to send to others.
64
+ - **Scripting:** drive it from Python, or let an AI agent do so (see below).
65
+
66
+ [Documentation](https://raycrafter-optical-design.github.io/raycrafter-docs/)
67
+
68
+ **Status:** pre-alpha. Expect anything to change, including the API.
69
+
70
+
71
+ ## Install and run
72
+
73
+ ```
74
+ pip install raycrafter
75
+ raycrafter
76
+ ```
77
+
78
+ Or, with [uv](https://docs.astral.sh/uv/): `uvx raycrafter`.
79
+
80
+ To run the current development version from the `main` branch on GitHub, use uv directly
81
+ (no clone or install step needed):
82
+
83
+ ```
84
+ uvx --from git+https://github.com/raycrafter-optical-design/raycrafter@main raycrafter
85
+ ```
86
+
87
+ The MCP server from `main` can be run the same way (see below):
88
+
89
+ ```
90
+ uvx --from "raycrafter[mcp] @ git+https://github.com/raycrafter-optical-design/raycrafter@main" raycrafter-mcp
91
+ ```
92
+
93
+ `main` may contain changes not yet in the PyPI release, so behaviour may differ from
94
+ `pip install raycrafter`.
95
+
96
+
97
+ ## Use it from Python
98
+
99
+ ```python
100
+ from raycrafter import Bench
101
+
102
+ bench = Bench(empty=True) # or Bench.connect() to drive the open window
103
+ bench.add_lens("AC254-100-A")
104
+ bench.add_lens("AC254-050-A", front_z_mm=150)
105
+ bench.autofocus()
106
+ print(bench.summary())
107
+ bench.plot("spot_diagram").savefig("spot.png")
108
+ ```
109
+
110
+ Every method is documented, with examples, in `raycrafter/api.py`.
111
+
112
+
113
+ ## Use it from an AI agent
114
+
115
+ RayCrafter includes an [MCP](https://modelcontextprotocol.io) server, so an AI agent such as
116
+ Claude can search for lenses, build and edit a design, and read back the optics.
117
+
118
+ If a RayCrafter window is open, the agent controls that window: you watch its changes happen,
119
+ and you can also move lenses yourself and ask the agent about the result. (The window listens
120
+ only on your own computer, and writes a private file in `~/.raycrafter` so the server can find
121
+ it. Start with `raycrafter --no-agent-link` to turn this off.) If no window is open, the server
122
+ works on a design of its own, with no picture. Every result says which one it came from.
123
+
124
+ **1. Install the MCP extra.**
125
+
126
+ - With pip: `pip install "raycrafter[mcp]"`. This installs the `raycrafter-mcp` command.
127
+ - With [uv](https://docs.astral.sh/uv/): `uv tool install "raycrafter[mcp]"` installs both
128
+ `raycrafter` and `raycrafter-mcp`. Or install nothing and let uv fetch it on demand; see the
129
+ `uvx` setting below.
130
+
131
+ **2. Tell your MCP client where it is.** In the Claude desktop app, open Settings, then
132
+ Developer, then Edit Config. This opens the file `claude_desktop_config.json`, which is at
133
+ `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows. Add
134
+ RayCrafter under `mcpServers`, then quit and reopen the app:
135
+
136
+ ```json
137
+ {
138
+ "mcpServers": {
139
+ "raycrafter": {
140
+ "command": "/full/path/to/raycrafter-mcp"
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ The path must be written out in full: the app does not expand `~`, and it may not see the same
147
+ `PATH` as your terminal. Find the path with `which raycrafter-mcp` (macOS, Linux) or
148
+ `where raycrafter-mcp` (Windows).
149
+
150
+ If you use uv and installed nothing, run RayCrafter through `uvx` instead (find its path with
151
+ `which uvx`):
152
+
153
+ ```json
154
+ {
155
+ "mcpServers": {
156
+ "raycrafter": {
157
+ "command": "/full/path/to/uvx",
158
+ "args": ["--from", "raycrafter[mcp]", "raycrafter-mcp"]
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
164
+ Other MCP clients (for example Claude Code: `claude mcp add raycrafter -- raycrafter-mcp`) take
165
+ the same command.
166
+
167
+
168
+ ## An agent-generated project
169
+
170
+ The code in this repository is written by AI coding agents, working with the project's
171
+ developers. Due to time constraints, the project is only possible because of agentic
172
+ coding.
173
+
174
+ We nonetheless aim for well-designed, readable code that people who use little or no AI can
175
+ understand and contribute to. The rules the agents follow are in [CLAUDE.md](CLAUDE.md), and
176
+ significant decisions, with their reasons, are recorded in the topic files of
177
+ [agent_docs/](agent_docs/README.md). How agents use those notes, and how to run several agents
178
+ at once, is explained in [AGENT_WORKFLOW.md](AGENT_WORKFLOW.md).
@@ -0,0 +1,139 @@
1
+ # RayCrafter
2
+
3
+ [![Python Version](https://img.shields.io/pypi/pyversions/raycrafter.svg)](https://pypi.org/project/raycrafter)
4
+ [![PyPI Version](https://img.shields.io/pypi/v/raycrafter.svg)](https://pypi.org/project/raycrafter)
5
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/raycrafter-optical-design/raycrafter/blob/main/LICENSE)
6
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/raycrafter-optical-design/raycrafter/test_and_deploy.yml?branch=main&label=CI)](https://github.com/raycrafter-optical-design/raycrafter/actions/workflows/test_and_deploy.yml)
7
+ [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
9
+ [![codecov](https://codecov.io/gh/raycrafter-optical-design/raycrafter/branch/main/graph/badge.svg)](https://codecov.io/gh/raycrafter-optical-design/raycrafter)
10
+
11
+ RayCrafter is an early proof of principle for a lens-level optical design tool. You place
12
+ off-the-shelf lenses on an optical axis, drag them around, and see the spot diagram,
13
+ through-focus curve, MTF, ray fan, field curvature and distortion update as you go. The ray
14
+ tracing is done by [Optiland](https://github.com/optiland/optiland).
15
+
16
+ - **Lenses:** the Thorlabs spherical lenses, achromats, air-spaced doublets, triplets and
17
+ matched pairs, plus ideal (paraxial) lenses.
18
+ - **Layout:** type the gaps between lenses and lock them; group lenses into assemblies (such
19
+ as Plossl pairs) and save them as your own parts.
20
+ - **Beams:** any number, each with its own width, angle, vergence, offset and wavelength.
21
+ - **3D view:** View > Show 3D View shows the lenses and rays in a window you can rotate.
22
+ - **Files:** save designs as RayCrafter project files, import and export Zemax `.zmx` files,
23
+ and open a report with a 3D view in your browser, which updates as you change the design
24
+ and can be saved as one file to send to others.
25
+ - **Scripting:** drive it from Python, or let an AI agent do so (see below).
26
+
27
+ [Documentation](https://raycrafter-optical-design.github.io/raycrafter-docs/)
28
+
29
+ **Status:** pre-alpha. Expect anything to change, including the API.
30
+
31
+
32
+ ## Install and run
33
+
34
+ ```
35
+ pip install raycrafter
36
+ raycrafter
37
+ ```
38
+
39
+ Or, with [uv](https://docs.astral.sh/uv/): `uvx raycrafter`.
40
+
41
+ To run the current development version from the `main` branch on GitHub, use uv directly
42
+ (no clone or install step needed):
43
+
44
+ ```
45
+ uvx --from git+https://github.com/raycrafter-optical-design/raycrafter@main raycrafter
46
+ ```
47
+
48
+ The MCP server from `main` can be run the same way (see below):
49
+
50
+ ```
51
+ uvx --from "raycrafter[mcp] @ git+https://github.com/raycrafter-optical-design/raycrafter@main" raycrafter-mcp
52
+ ```
53
+
54
+ `main` may contain changes not yet in the PyPI release, so behaviour may differ from
55
+ `pip install raycrafter`.
56
+
57
+
58
+ ## Use it from Python
59
+
60
+ ```python
61
+ from raycrafter import Bench
62
+
63
+ bench = Bench(empty=True) # or Bench.connect() to drive the open window
64
+ bench.add_lens("AC254-100-A")
65
+ bench.add_lens("AC254-050-A", front_z_mm=150)
66
+ bench.autofocus()
67
+ print(bench.summary())
68
+ bench.plot("spot_diagram").savefig("spot.png")
69
+ ```
70
+
71
+ Every method is documented, with examples, in `raycrafter/api.py`.
72
+
73
+
74
+ ## Use it from an AI agent
75
+
76
+ RayCrafter includes an [MCP](https://modelcontextprotocol.io) server, so an AI agent such as
77
+ Claude can search for lenses, build and edit a design, and read back the optics.
78
+
79
+ If a RayCrafter window is open, the agent controls that window: you watch its changes happen,
80
+ and you can also move lenses yourself and ask the agent about the result. (The window listens
81
+ only on your own computer, and writes a private file in `~/.raycrafter` so the server can find
82
+ it. Start with `raycrafter --no-agent-link` to turn this off.) If no window is open, the server
83
+ works on a design of its own, with no picture. Every result says which one it came from.
84
+
85
+ **1. Install the MCP extra.**
86
+
87
+ - With pip: `pip install "raycrafter[mcp]"`. This installs the `raycrafter-mcp` command.
88
+ - With [uv](https://docs.astral.sh/uv/): `uv tool install "raycrafter[mcp]"` installs both
89
+ `raycrafter` and `raycrafter-mcp`. Or install nothing and let uv fetch it on demand; see the
90
+ `uvx` setting below.
91
+
92
+ **2. Tell your MCP client where it is.** In the Claude desktop app, open Settings, then
93
+ Developer, then Edit Config. This opens the file `claude_desktop_config.json`, which is at
94
+ `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows. Add
95
+ RayCrafter under `mcpServers`, then quit and reopen the app:
96
+
97
+ ```json
98
+ {
99
+ "mcpServers": {
100
+ "raycrafter": {
101
+ "command": "/full/path/to/raycrafter-mcp"
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ The path must be written out in full: the app does not expand `~`, and it may not see the same
108
+ `PATH` as your terminal. Find the path with `which raycrafter-mcp` (macOS, Linux) or
109
+ `where raycrafter-mcp` (Windows).
110
+
111
+ If you use uv and installed nothing, run RayCrafter through `uvx` instead (find its path with
112
+ `which uvx`):
113
+
114
+ ```json
115
+ {
116
+ "mcpServers": {
117
+ "raycrafter": {
118
+ "command": "/full/path/to/uvx",
119
+ "args": ["--from", "raycrafter[mcp]", "raycrafter-mcp"]
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ Other MCP clients (for example Claude Code: `claude mcp add raycrafter -- raycrafter-mcp`) take
126
+ the same command.
127
+
128
+
129
+ ## An agent-generated project
130
+
131
+ The code in this repository is written by AI coding agents, working with the project's
132
+ developers. Due to time constraints, the project is only possible because of agentic
133
+ coding.
134
+
135
+ We nonetheless aim for well-designed, readable code that people who use little or no AI can
136
+ understand and contribute to. The rules the agents follow are in [CLAUDE.md](CLAUDE.md), and
137
+ significant decisions, with their reasons, are recorded in the topic files of
138
+ [agent_docs/](agent_docs/README.md). How agents use those notes, and how to run several agents
139
+ at once, is explained in [AGENT_WORKFLOW.md](AGENT_WORKFLOW.md).