lcode-cli 0.48.0__tar.gz → 0.49.1__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 (214) hide show
  1. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/CHANGELOG.md +42 -1
  2. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/PKG-INFO +7 -5
  3. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/README.md +6 -4
  4. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/configuration.md +2 -2
  5. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/mcp.md +4 -2
  6. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/modes.md +74 -11
  7. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/quickstart.md +1 -1
  8. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/__init__.py +1 -1
  9. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/agent.py +1 -0
  10. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/cli.py +12 -0
  11. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/film.py +11 -5
  12. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/hardware.py +49 -0
  13. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/media.py +116 -23
  14. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/media.toml +33 -1
  15. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/media_catalog.py +27 -11
  16. lcode_cli-0.49.1/src/lcode/media_cloud.py +461 -0
  17. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/modes.py +10 -9
  18. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/repl.py +7 -0
  19. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/residency.py +33 -0
  20. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/conftest.py +3 -0
  21. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_comfy.py +4 -2
  22. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_film.py +7 -1
  23. lcode_cli-0.49.1/tests/test_gpu_handover.py +156 -0
  24. lcode_cli-0.49.1/tests/test_media_cloud.py +263 -0
  25. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.editorconfig +0 -0
  26. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/CODEOWNERS +0 -0
  27. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  28. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  29. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  30. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/ISSUE_TEMPLATE/model_request.yml +0 -0
  31. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  32. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/dependabot.yml +0 -0
  33. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/workflows/ci.yml +0 -0
  34. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/workflows/docs.yml +0 -0
  35. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.github/workflows/release.yml +0 -0
  36. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.gitignore +0 -0
  37. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/.pre-commit-config.yaml +0 -0
  38. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/AGENTS.md +0 -0
  39. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/CODE_OF_CONDUCT.md +0 -0
  40. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/CONTRIBUTING.md +0 -0
  41. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/LICENSE +0 -0
  42. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/SECURITY.md +0 -0
  43. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/action.yml +0 -0
  44. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/agents.md +0 -0
  45. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/assets/demo.svg +0 -0
  46. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/assets/extra.css +0 -0
  47. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/assets/film-fox-and-kitten.jpg +0 -0
  48. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/automation.md +0 -0
  49. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/bench.md +0 -0
  50. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/changelog.md +0 -0
  51. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/commands.md +0 -0
  52. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/contributing.md +0 -0
  53. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/editors.md +0 -0
  54. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/git.md +0 -0
  55. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/hooks.md +0 -0
  56. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/how-it-works.md +0 -0
  57. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/index.md +0 -0
  58. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/installation.md +0 -0
  59. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/lsp.md +0 -0
  60. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/memory.md +0 -0
  61. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/models.md +0 -0
  62. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/sandbox.md +0 -0
  63. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/search.md +0 -0
  64. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/servers.md +0 -0
  65. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/troubleshooting.md +0 -0
  66. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/docs/usage.md +0 -0
  67. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/examples/README.md +0 -0
  68. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/examples/api/fix_tests.py +0 -0
  69. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/examples/commands/review.md +0 -0
  70. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/examples/skills/commit-message/SKILL.md +0 -0
  71. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/examples/skills/commit-message/scripts/staged.sh +0 -0
  72. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/install.sh +0 -0
  73. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/mkdocs.yml +0 -0
  74. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/overrides/main.html +0 -0
  75. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/pyproject.toml +0 -0
  76. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/scripts/make_logos.py +0 -0
  77. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/scripts/record_demo.py +0 -0
  78. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/scripts/social-preview.html +0 -0
  79. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/__main__.py +0 -0
  80. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/acp.py +0 -0
  81. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/action.py +0 -0
  82. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/api.py +0 -0
  83. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/assistant.py +0 -0
  84. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/backends.py +0 -0
  85. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/bench.py +0 -0
  86. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/bench_backend.py +0 -0
  87. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/bench_runtime.py +0 -0
  88. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/catalog.py +0 -0
  89. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/checkpoints.py +0 -0
  90. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/checks.py +0 -0
  91. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/clipboard.py +0 -0
  92. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/cloud.py +0 -0
  93. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/codesearch.py +0 -0
  94. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/comfy.py +0 -0
  95. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/config.py +0 -0
  96. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/context.py +0 -0
  97. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/edits.py +0 -0
  98. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/escalate.py +0 -0
  99. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/extensions.py +0 -0
  100. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/frontmatter.py +0 -0
  101. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/gitflow.py +0 -0
  102. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/hooks.py +0 -0
  103. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/imageopts.py +0 -0
  104. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/jobs.py +0 -0
  105. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/limits.py +0 -0
  106. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/lsp.py +0 -0
  107. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/matching.py +0 -0
  108. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/__init__.py +0 -0
  109. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/auth.py +0 -0
  110. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/catalog.py +0 -0
  111. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/catalog.toml +0 -0
  112. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/client.py +0 -0
  113. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/commands.py +0 -0
  114. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/config.py +0 -0
  115. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/http.py +0 -0
  116. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/manager.py +0 -0
  117. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/protocol.py +0 -0
  118. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/server.py +0 -0
  119. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/mcp/stdio.py +0 -0
  120. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/memory.py +0 -0
  121. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/models.toml +0 -0
  122. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/notify.py +0 -0
  123. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/ollama.py +0 -0
  124. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/permissions.py +0 -0
  125. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/planning.py +0 -0
  126. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/preview.py +0 -0
  127. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/render.py +0 -0
  128. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/repeats.py +0 -0
  129. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/repomap.py +0 -0
  130. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/review.py +0 -0
  131. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/sandbox.py +0 -0
  132. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/screenshots.py +0 -0
  133. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/secretscan.py +0 -0
  134. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/servers/__init__.py +0 -0
  135. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/servers/encord.py +0 -0
  136. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/servers/valohai.py +0 -0
  137. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/servers/xai.py +0 -0
  138. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/sessions.py +0 -0
  139. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/steer.py +0 -0
  140. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/subagents.py +0 -0
  141. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/tools.py +0 -0
  142. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/unreachable.py +0 -0
  143. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/update.py +0 -0
  144. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/vision.py +0 -0
  145. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/web.py +0 -0
  146. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/__init__.py +0 -0
  147. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/flux2-klein-4b-t2i.json +0 -0
  148. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/remove-background.json +0 -0
  149. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/smooth-film.json +0 -0
  150. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/sound-stable-audio.json +0 -0
  151. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/upscale-esrgan.json +0 -0
  152. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/upscale-video-esrgan.json +0 -0
  153. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan21-fun-camera.json +0 -0
  154. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan21-vace.json +0 -0
  155. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan22-fun-inp-5b.json +0 -0
  156. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/wan22-ti2v-5b.json +0 -0
  157. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/src/lcode/workflows/z-image-turbo-t2i.json +0 -0
  158. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/comfy_standin.py +0 -0
  159. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/fake_lsp_server.py +0 -0
  160. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/fake_mcp_server.py +0 -0
  161. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_acp.py +0 -0
  162. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_action.py +0 -0
  163. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_agent.py +0 -0
  164. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_api.py +0 -0
  165. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_assistant.py +0 -0
  166. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_backends.py +0 -0
  167. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_bench.py +0 -0
  168. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_catalog.py +0 -0
  169. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_checkpoints.py +0 -0
  170. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_checks.py +0 -0
  171. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_cli.py +0 -0
  172. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_clipboard.py +0 -0
  173. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_cloud.py +0 -0
  174. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_codesearch.py +0 -0
  175. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_config.py +0 -0
  176. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_context.py +0 -0
  177. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_context_picker.py +0 -0
  178. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_escalate.py +0 -0
  179. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_extensions.py +0 -0
  180. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_gitflow.py +0 -0
  181. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_hooks.py +0 -0
  182. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_image_edit.py +0 -0
  183. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_image_generate.py +0 -0
  184. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_jobs.py +0 -0
  185. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_look.py +0 -0
  186. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_lsp.py +0 -0
  187. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_matching.py +0 -0
  188. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_mcp.py +0 -0
  189. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_media_catalog.py +0 -0
  190. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_memory.py +0 -0
  191. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_model_picker.py +0 -0
  192. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_modes.py +0 -0
  193. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_permissions.py +0 -0
  194. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_plan_mode.py +0 -0
  195. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_repeats.py +0 -0
  196. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_repomap.py +0 -0
  197. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_residency.py +0 -0
  198. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_review.py +0 -0
  199. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_robustness.py +0 -0
  200. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_sandbox.py +0 -0
  201. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_screenshots.py +0 -0
  202. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_secretscan.py +0 -0
  203. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_servers.py +0 -0
  204. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_sessions.py +0 -0
  205. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_steer.py +0 -0
  206. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_stuck.py +0 -0
  207. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_subagents.py +0 -0
  208. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_tools.py +0 -0
  209. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_update.py +0 -0
  210. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_video.py +0 -0
  211. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_vision.py +0 -0
  212. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_web.py +0 -0
  213. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/tests/test_xai.py +0 -0
  214. {lcode_cli-0.48.0 → lcode_cli-0.49.1}/uv.lock +0 -0
@@ -6,6 +6,45 @@ All notable changes to lcode are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.49.1] - 2026-10-26
10
+
11
+ ### Fixed
12
+
13
+ - **Image and video jobs no longer run out of GPU memory right after switching modes.** Switching
14
+ to video mode in the first half minute after lcode starts unloaded the coding model while it was
15
+ still loading; the load then finished and kept the GPU (10.8 GB of 12 here), and the next job
16
+ sent to ComfyUI ran out of memory. A load that ends outside code mode now unloads itself, a job
17
+ waits for a load still going, and unloading waits until Ollama has really freed the memory.
18
+ - **Running out of GPU memory says what holds it** (`Other programs hold GPU memory: obs
19
+ (1.6 GB)…`) instead of ComfyUI's whole error, and lcode starts its ComfyUI afresh: after running
20
+ out of memory ComfyUI crashed on the next job. A crash now says it was one, with the log's path,
21
+ instead of "ComfyUI closed the websocket".
22
+ - **A nearly full disk stops a job before it starts** (under 1 GB free), and ComfyUI's "No space
23
+ left on device" is said plainly: a film used to stop at shot 6 on it.
24
+
25
+ ## [0.49.0] - 2026-10-24
26
+
27
+ ### Added
28
+
29
+ - **Cloud generation in image and video mode** (#157): xAI's Grok Imagine as cloud models,
30
+ `grok-image` (pictures, edits of one picture) and `grok-video` (clips from text or a start
31
+ picture), chosen with `/model` and marked *cloud* in `/models` and `lcode media`. Before each
32
+ request lcode shows what goes where and about what it costs, and sends nothing until you say yes;
33
+ the session's total is shown after. The key comes from `XAI_API_KEY` only and goes to xAI's API
34
+ only. What a cloud model can't do here (masks, several pictures, clips between two frames…) is
35
+ made by a local model. See [In the cloud](https://nasser1941.github.io/lcode/modes/#in-the-cloud-grok-imagine).
36
+
37
+ ### Changed
38
+
39
+ - The README no longer says code mode makes images through MCP servers (it hasn't since 0.40.0).
40
+
41
+ ### Fixed
42
+
43
+ - **Films:** things and places no longer become cast members. A kite in the cast got a "character" picture
44
+ (a person behind a kite) and walked on legs in every shot. The storyboard now keeps the cast to living
45
+ characters and describes things in the shots: in 12 storyboards for ideas with props, things in the cast
46
+ went from 6 to 1 (a plant).
47
+
9
48
  ## [0.48.0] - 2026-10-24
10
49
 
11
50
  ### Added
@@ -1026,7 +1065,9 @@ First public release.
1026
1065
  - `AGENTS.md` project instructions and `/init` to generate them.
1027
1066
  - One-line installer for Linux and macOS.
1028
1067
 
1029
- [Unreleased]: https://github.com/nasser1941/lcode/compare/v0.48.0...HEAD
1068
+ [Unreleased]: https://github.com/nasser1941/lcode/compare/v0.49.1...HEAD
1069
+ [0.49.1]: https://github.com/nasser1941/lcode/compare/v0.49.0...v0.49.1
1070
+ [0.49.0]: https://github.com/nasser1941/lcode/compare/v0.48.0...v0.49.0
1030
1071
  [0.48.0]: https://github.com/nasser1941/lcode/compare/v0.47.0...v0.48.0
1031
1072
  [0.47.0]: https://github.com/nasser1941/lcode/compare/v0.46.0...v0.47.0
1032
1073
  [0.46.0]: https://github.com/nasser1941/lcode/compare/v0.45.0...v0.46.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lcode-cli
3
- Version: 0.48.0
3
+ Version: 0.49.1
4
4
  Summary: A local-first terminal coding agent powered by open-weight models on your own GPU or Mac, via Ollama.
5
5
  Project-URL: Homepage, https://nasser1941.github.io/lcode/
6
6
  Project-URL: Documentation, https://nasser1941.github.io/lcode/
@@ -118,11 +118,13 @@ through [Ollama](https://ollama.com), and when it needs current information it c
118
118
  with tool calling. Or use LM Studio, llama.cpp, vLLM or MLX instead of Ollama.
119
119
  - **MCP servers, ready to go.** Connect Jira and Confluence, GitHub, AWS, Google Drive, Grafana,
120
120
  Google Cloud, Sentry, Linear, Notion, Postgres, Kubernetes, Metabase, Encord, Valohai and more with one command
121
- (`lcode mcp add atlassian`), image generation with ComfyUI, or any other MCP server. Browser sign-in (OAuth) is built in.
121
+ (`lcode mcp add atlassian`), or any other MCP server. Browser sign-in (OAuth) is built in.
122
122
  - **Sees images.** Attach a screenshot or mockup with `@path` and lcode looks at it, using the
123
- vision part of your model. With ComfyUI (`lcode mcp add comfyui`) it can also generate and edit
124
- images with local models such as FLUX, SDXL and Qwen-Image, or, in the cloud, images, videos
125
- and speech with xAI's Grok Imagine (`lcode mcp add xai`).
123
+ vision part of your model.
124
+ - **Images, videos and films.** Image and video [modes](https://nasser1941.github.io/lcode/modes/)
125
+ (`/mode image`) make pictures, edits, clips and short films with local models run by ComfyUI
126
+ (FLUX.2 klein, Wan 2.2, installed on demand), or with xAI's Grok Imagine and your own key, after
127
+ showing what it costs.
126
128
  - **Web search when needed.** Looks up the latest versions, docs and error messages with Ollama web
127
129
  search, Brave, Tavily or your own SearXNG, and reads pages as clean text.
128
130
  - **Private.** The model runs on your machine, lcode never uploads your files and has no telemetry.
@@ -82,11 +82,13 @@ through [Ollama](https://ollama.com), and when it needs current information it c
82
82
  with tool calling. Or use LM Studio, llama.cpp, vLLM or MLX instead of Ollama.
83
83
  - **MCP servers, ready to go.** Connect Jira and Confluence, GitHub, AWS, Google Drive, Grafana,
84
84
  Google Cloud, Sentry, Linear, Notion, Postgres, Kubernetes, Metabase, Encord, Valohai and more with one command
85
- (`lcode mcp add atlassian`), image generation with ComfyUI, or any other MCP server. Browser sign-in (OAuth) is built in.
85
+ (`lcode mcp add atlassian`), or any other MCP server. Browser sign-in (OAuth) is built in.
86
86
  - **Sees images.** Attach a screenshot or mockup with `@path` and lcode looks at it, using the
87
- vision part of your model. With ComfyUI (`lcode mcp add comfyui`) it can also generate and edit
88
- images with local models such as FLUX, SDXL and Qwen-Image, or, in the cloud, images, videos
89
- and speech with xAI's Grok Imagine (`lcode mcp add xai`).
87
+ vision part of your model.
88
+ - **Images, videos and films.** Image and video [modes](https://nasser1941.github.io/lcode/modes/)
89
+ (`/mode image`) make pictures, edits, clips and short films with local models run by ComfyUI
90
+ (FLUX.2 klein, Wan 2.2, installed on demand), or with xAI's Grok Imagine and your own key, after
91
+ showing what it costs.
90
92
  - **Web search when needed.** Looks up the latest versions, docs and error messages with Ollama web
91
93
  search, Brave, Tavily or your own SearXNG, and reads pages as clean text.
92
94
  - **Private.** The model runs on your machine, lcode never uploads your files and has no telemetry.
@@ -30,8 +30,8 @@ lcode config path # print the file location
30
30
  | `preview` | `auto` | Images in the terminal: `auto`, `kitty`, `iterm`, `blocks` (colour text) or `off` ([results](modes.md#results)) |
31
31
  | `prompt_assistant` | `video` | A small model writes fuller prompts: `video`, `all` (pictures and follow-ups too), `off`, or an Ollama model ([prompt assistant](modes.md#the-prompt-assistant)) |
32
32
  | `check_results` | `false` | The prompt assistant checks each picture against the request |
33
- | `video_model` | `wan22-ti2v-5b` | The model video mode uses: a key from `lcode media` ([video mode](modes.md#video-mode)) |
34
- | `image_model` | `flux2-klein-4b` | The model image mode uses: a key from `lcode media` ([image models](modes.md#image-models)) |
33
+ | `video_model` | `wan22-ti2v-5b` | The model video mode uses: a key from `lcode media` ([video mode](modes.md#video-mode)); `grok-video` runs at xAI ([in the cloud](modes.md#in-the-cloud-grok-imagine)) |
34
+ | `image_model` | `flux2-klein-4b` | The model image mode uses: a key from `lcode media` ([image models](modes.md#image-models)); `grok-image` runs at xAI ([in the cloud](modes.md#in-the-cloud-grok-imagine)) |
35
35
  | `think` | `true` | Let the model reason before answering |
36
36
  | `web` | `on` | Web search and page fetching: `on`, `ask` (before each search/website) or `off` |
37
37
  | `search_backend` | `auto` | `auto`, `ollama`, `brave`, `tavily` or `searxng`; `auto` uses the first one configured |
@@ -89,8 +89,10 @@ details.
89
89
 
90
90
  Code mode makes code only, so the servers that generated images and videos in earlier versions
91
91
  (`comfyui`, `xai`) aren't in the catalog any more, and lcode doesn't load them in code mode if
92
- they're still in your `mcp.json`. Image and video generation get their own [modes](modes.md),
93
- with their own models and controls.
92
+ they're still in your `mcp.json`. Image and video generation have their own [modes](modes.md),
93
+ with their own models and controls, and Grok Imagine is there as a
94
+ [cloud model](modes.md#in-the-cloud-grok-imagine). The `lcode-mcp-xai` server still works with
95
+ other MCP clients, for speech too.
94
96
 
95
97
  ### Metabase
96
98
 
@@ -5,8 +5,8 @@ lcode makes three kinds of things, each in its own mode with its own models:
5
5
  | Mode | What it makes | The model doing the work |
6
6
  |---|---|---|
7
7
  | **code** (default) | Code: it reads, writes, runs and checks your project | A coding language model in Ollama (or another server) |
8
- | **image** | Images from a description, edits of your images (references, inpainting, outpainting), upscales and cut-outs | An image model, run by ComfyUI on your GPU |
9
- | **video** | Video clips from a description or a start image | A video model, run by ComfyUI on your GPU |
8
+ | **image** | Images from a description, edits of your images (references, inpainting, outpainting), upscales and cut-outs | An image model, run by ComfyUI on your GPU, or [in the cloud](#in-the-cloud-grok-imagine) |
9
+ | **video** | Video clips from a description or a start image, and [films](#films) | A video model, run by ComfyUI on your GPU, or [in the cloud](#in-the-cloud-grok-imagine) |
10
10
 
11
11
  ```text
12
12
  ❯ /mode image
@@ -216,7 +216,8 @@ The Fox and the Kitten (.lcode/media/films/the-fox-and-the-kitten)
216
216
  ![The cast's reference pictures (right) and a frame from each of the three shots](assets/film-fox-and-kitten.jpg)
217
217
 
218
218
  1. **The storyboard:** the [prompt assistant](#the-prompt-assistant) writes it from your idea: the
219
- look of the whole film, the cast (each character described once) and the shots (what happens,
219
+ look of the whole film, the cast (each living character described once; things like a kite or a car are
220
+ described in the shots) and the shots (what happens,
220
221
  the camera, who's in it, how long). It's saved as `storyboard.json` (and a readable
221
222
  `storyboard.md`) in the film's folder.
222
223
  2. **The cast:** each character gets a reference picture, made once, in `cast/`.
@@ -286,6 +287,65 @@ assistant:
286
287
  - **The check** said every one of the six pictures matched, which they did; it hasn't been
287
288
  measured on pictures that miss.
288
289
 
290
+ ## In the cloud: Grok Imagine
291
+
292
+ For what a laptop can't run, or when speed matters, image and video mode can use xAI's Grok Imagine
293
+ with your own API key. It's chosen like a local model and marked *cloud* in `/models` and `lcode
294
+ media`. lcode reads the key from the environment only:
295
+
296
+ ```bash
297
+ export XAI_API_KEY=xai-… # from https://console.x.ai, then start lcode
298
+ ```
299
+
300
+ ```text
301
+ image ❯ /model grok-image
302
+ Image model: Grok Imagine Image 2.0.
303
+ ◆ Grok Imagine Image 2.0 runs at xAI: each request shows what goes there and about what it costs ($0.04 per image), and asks first.
304
+ image ❯ a red fox in the snow --n 2
305
+ ╭─ Make it at xAI? ─────────────────────────────────────────────────────────────────────────────╮
306
+ │ Where: Grok Imagine Image 2.0 (grok-imagine-image-2.0) at xAI, api.x.ai │
307
+ │ What goes: the prompt. Your XAI_API_KEY goes with it, to api.x.ai only. │
308
+ │ Prompt: a red fox in the snow │
309
+ │ Cost: about $0.08 (2 images × $0.04), billed to your xAI account; prices as of 2026-10-24, the │
310
+ │ real ones: https://docs.x.ai/developers/pricing │
311
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯
312
+ Send it to xAI (about $0.08)? [y/N] y
313
+ ◆ #1 .lcode/media/20261024-153907-a-red-fox-in-the-snow-1.jpg … · Grok Imagine Image 2.0 · … s
314
+ ◆ #2 .lcode/media/20261024-153907-a-red-fox-in-the-snow-2.jpg … · Grok Imagine Image 2.0 · … s
315
+ about $0.08 at xAI (this session: about $0.08)
316
+ ```
317
+
318
+ | Model | `/model` | Makes | Price (xAI's, on 2026-10-24) |
319
+ |---|---|---|---|
320
+ | **Grok Imagine Image 2.0** | `grok-image` | Pictures from text; edits of one picture | $0.04 per picture, 1k or 2k; $0.01 per picture sent |
321
+ | **Grok Imagine Video 1.5** | `grok-video` | Clips from text or a start picture | Per second: $0.08 at 480p, $0.14 at 720p, $0.25 at 1080p; $0.01 per picture sent |
322
+
323
+ - **What's sent:** the prompt (the [prompt assistant](#the-prompt-assistant)'s fuller one when it
324
+ wrote one, shown above the panel) and the picture you edit or start a clip from. Nothing else:
325
+ not your project, not other pictures, not the conversation.
326
+ - **The key** goes in the request's `Authorization` header to xAI's API, and nowhere else. Results
327
+ are downloaded from the address xAI gives, without it. `XAI_API_BASE` sends the requests, key
328
+ included, to another address, such as a proxy you run.
329
+ - **What it costs** is shown before every request, from lcode's copy of xAI's prices with the date
330
+ they were checked, and nothing is sent until you say yes. The line under the results adds it to
331
+ the session's total. It's an estimate: xAI bills by its [pricing page](https://docs.x.ai/developers/pricing).
332
+ - **Options:** `--quality` picks the resolution: pictures are 1k (`fast`, `balanced`) or 2k
333
+ (`best`), at the same price; clips are 480p, 720p or 1080p. `--ar` picks the nearest shape xAI
334
+ offers. `--camera` becomes words in the prompt. Seeds and `--no` aren't used.
335
+ - **What it doesn't do here** is made by a local model, and lcode says which: masks, several
336
+ pictures at once and extending a picture (FLUX.2 klein); clips between two frames, reference
337
+ pictures, extending and restyling a clip (the Wan models).
338
+ - **Stopping:** Esc or Ctrl+C stops waiting for a clip, but xAI may still make it and bill it. The
339
+ message gives the request's id.
340
+ - **No terminal, no cloud:** `lcode -p` in image or video mode refuses a cloud model, because
341
+ nobody can say yes to the cost.
342
+ - **[Films](#films)** work with cloud models too; each picture and clip asks.
343
+ - **Files:** results land in the media folder and the gallery as local ones do. The JSON next to
344
+ each says what was sent, to which model, the estimated cost and xAI's request id for a clip.
345
+ xAI's terms and usage policies apply to what you send.
346
+ - **Tested** against a stand-in for xAI's API that answers as its documentation describes; prices
347
+ are from xAI's pricing page.
348
+
289
349
  ## ComfyUI
290
350
 
291
351
  ComfyUI runs the image and video models; lcode drives it through its API.
@@ -372,18 +432,21 @@ memory a model *needs* is lower than what `nvidia-smi` shows while it runs.
372
432
 
373
433
  ## One model on the GPU at a time
374
434
 
375
- Image and video modes don't need the big coding model: the image or video model does the work. A
376
- small optional model will help with prompts later. Image and video models need the GPU to
377
- themselves:
435
+ Image and video modes don't need the big coding model: the image or video model does the work, and
436
+ the [prompt assistant](#the-prompt-assistant) loads only while it writes. Image and video models
437
+ need the GPU to themselves:
378
438
 
379
439
  - **Into image or video mode:** lcode unloads its coding model from Ollama, and checks again
380
- before each image.
440
+ before each image. It waits until the memory is really free (Ollama lets go of it a moment after
441
+ it answers). If the coding model was still loading when you switched, as it is in the first half
442
+ minute after lcode starts, the job waits for that load to end and unloads it.
381
443
  - **Back to code mode:** lcode stops the ComfyUI it started, or asks yours to free its memory,
382
444
  then loads the coding model again in the background.
383
-
384
- ## Coming next
385
-
386
- - **#157 Cloud generation**, with costs shown (Grok Imagine first).
445
+ - **Other programs on the GPU** leave less room. When a job runs out of GPU memory, lcode names
446
+ what holds it (`obs (1.6 GB)`, `render.py (2.0 GB)`) and starts its ComfyUI afresh for the next request:
447
+ after running out of memory, ComfyUI can crash on the next job. If it crashes anyway, lcode says
448
+ so and points to its log (`comfyui.log` in lcode's state folder).
449
+ - **A nearly full disk** (under 1 GB free) stops a job before it starts, rather than at its end.
387
450
 
388
451
  The permission mode (`ask`, `plan`, `auto-edit`, `yolo`) is a different setting: `/permissions`
389
452
  sets it, and Shift+Tab cycles it as before.
@@ -12,7 +12,7 @@ lcode
12
12
 
13
13
  ```text
14
14
  ╭──────────────────────────────────────────────╮
15
- │ lcode v0.48.0 — local coding agent │
15
+ │ lcode v0.49.1 — local coding agent │
16
16
  │ │
17
17
  │ model lcode-qwen3.6-35b │
18
18
  │ context 256K tokens │
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.48.0"
6
+ __version__ = "0.49.1"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
@@ -385,6 +385,7 @@ class Agent:
385
385
  self.media_results: list[dict] = [] # the session's images, numbered (/gallery, /vary, /open)
386
386
  self.last_request: dict | None = None # what /again repeats (lcode.media.redo)
387
387
  self.image_refs: list[str] = [] # images every next request follows (/use)
388
+ self.cloud_spent = 0.0 # dollars, about, spent at cloud image and video models this session (media_cloud)
388
389
  self.reflected = 0 # messages before this index were already checked for notes to remember
389
390
  self._memory: memory_notes.Memory | None = None
390
391
  self._agent_types: tuple[Path, dict[str, subagents.AgentType], list[str]] | None = None
@@ -781,6 +781,13 @@ def comfyui_status(cfg: dict) -> tuple[str, bool | None]:
781
781
  from lcode import media_catalog as catalog
782
782
 
783
783
  model = catalog.load().find(cfg.get("image_model") or "") or catalog.load().models[catalog.DEFAULT_IMAGE]
784
+ if model.cloud:
785
+ from lcode import media_cloud
786
+
787
+ p = media_cloud.provider(model)
788
+ if not p.api_key():
789
+ return f"image model: {model.name}, at {p.name}, but {p.key_env} isn't set ({p.keys_url})", None
790
+ return f"image model: {model.name}, at {p.name} ({p.key_env} is set)", True
784
791
  server = comfy.Server(cfg["comfyui_url"])
785
792
  stats = server.stats()
786
793
  install = None if stats else comfy.find_install(cfg["comfyui_path"])
@@ -1085,6 +1092,11 @@ def cmd_media(args) -> None:
1085
1092
  model = cat.find(args.model or "")
1086
1093
  if model is None:
1087
1094
  fail(f"no media model {args.model!r}: lcode media lists them")
1095
+ if model.cloud:
1096
+ from lcode import media_cloud
1097
+
1098
+ console.print(f"Nothing to install: {media_cloud.ready_note(model)}")
1099
+ return
1088
1100
  if not running and install is None:
1089
1101
  fail(f"lcode needs ComfyUI to install models into. {comfy.install_hint()}")
1090
1102
  ask = None if args.yes else (lambda q: Confirm.ask(q, default=True, console=console))
@@ -1,8 +1,9 @@
1
1
  """Films: from one description to a short film with the same characters in every shot.
2
2
 
3
3
  1. **A storyboard.** The prompt assistant (lcode.assistant) writes it: a title, the look of the whole film, the cast
4
- (each character or place described once), and the shots (what happens, how long, the camera, who's in it). It's
5
- saved as `storyboard.json` in the film's folder, so it can be edited and made again.
4
+ (each living character described once; things and places are described in the shots), and the shots (what
5
+ happens, how long, the camera, who's in it). It's saved as `storyboard.json` in the film's folder, so it can be
6
+ edited and made again.
6
7
  2. **The cast.** Each character gets a reference picture (FLUX.2 klein), made once and kept in `cast/`.
7
8
  3. **The shots.** Each shot starts as a keyframe: a picture of the shot made with the cast's pictures as references,
8
9
  so the characters look the same from shot to shot. Video mode's model then animates the keyframe.
@@ -37,8 +38,10 @@ STORYBOARD = (
37
38
  '"what happens in this shot, where, and who is in it, in one or two sentences, using the cast names", "camera": '
38
39
  '"a shot type and camera move, like slow zoom in, tracking shot, static wide shot", "cast": ["names in this '
39
40
  'shot"], "seconds": {seconds}}}]}}\n'
40
- "Use one to three cast members, the same names in every shot. Each shot is one continuous moment; the film "
41
- "tells a small story from the first shot to the last. Describe what is seen, never what is felt or heard."
41
+ "The cast is one to three living characters (people, animals, creatures), with the same names in every shot. "
42
+ "Things and places are never cast members: a kite, a car, a house or a forest is described in the shots. Each "
43
+ "shot is one continuous moment; the film tells a small story from the first shot to the last. Describe what is "
44
+ "seen, never what is felt or heard."
42
45
  )
43
46
  TRANSITIONS = ("cut", "fade")
44
47
  FADE = 0.5 # seconds a fade takes
@@ -203,7 +206,10 @@ def make(
203
206
  if picture.exists():
204
207
  continue
205
208
  say(f"Cast: {name}")
206
- prompt = f"{board.look} Character reference of {name}: {desc}. Full body, facing the camera, plain background."
209
+ prompt = (
210
+ f"{board.look} Character reference of {name}, alone: {desc}. Full body, facing the camera, plain "
211
+ "background."
212
+ )
207
213
  made = with_mode(agent, "image", lambda p=prompt: media.generate_image(
208
214
  agent, p, cancelled, ask, imageopts.Options(size="3:4", quality=board.quality))) # fmt: skip
209
215
  keep(made.files[0], picture)
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import platform
6
6
  import subprocess
7
7
  from dataclasses import dataclass
8
+ from pathlib import Path
8
9
 
9
10
  GIB = 1024**3
10
11
 
@@ -46,6 +47,54 @@ def _run(cmd: list[str]) -> str:
46
47
  return ""
47
48
 
48
49
 
50
+ def gpu_used_gib() -> float | None:
51
+ """GPU memory in use on the NVIDIA GPUs, in GiB; None without nvidia-smi."""
52
+ out = _run(["nvidia-smi", "--query-gpu=memory.used", "--format=csv,noheader,nounits"])
53
+ try:
54
+ return sum(float(v) for v in out.split()) / 1024 if out else None
55
+ except ValueError:
56
+ return None
57
+
58
+
59
+ def gpu_users() -> list[tuple[str, float]]:
60
+ """The programs holding NVIDIA GPU memory, largest first: (a short name, GiB). Empty without nvidia-smi."""
61
+ out = _run(["nvidia-smi", "--query-compute-apps=pid,process_name,used_memory", "--format=csv,noheader,nounits"])
62
+ users: dict[str, float] = {}
63
+ for line in out.splitlines():
64
+ parts = [p.strip() for p in line.split(",")]
65
+ if len(parts) != 3:
66
+ continue
67
+ try:
68
+ gib = float(parts[2]) / 1024
69
+ except ValueError:
70
+ continue
71
+ name = program_name(parts[0], parts[1])
72
+ users[name] = users.get(name, 0.0) + gib
73
+ return sorted(users.items(), key=lambda item: -item[1])
74
+
75
+
76
+ def program_name(pid: str, process: str) -> str:
77
+ """A GPU program's short name, from its command line (/proc) or else nvidia-smi's process name."""
78
+ try:
79
+ argv = [a.decode(errors="replace") for a in Path(f"/proc/{pid}/cmdline").read_bytes().split(b"\0") if a]
80
+ except OSError:
81
+ argv = []
82
+ return name_from(argv or [process], process)
83
+
84
+
85
+ def name_from(argv: list[str], process: str = "") -> str:
86
+ """'render.py' for `python3 render.py`, 'ComfyUI' for its main.py, 'Ollama', else the program."""
87
+ program = Path(argv[0]).name if argv else process
88
+ if program.startswith("python") and len(argv) > 1:
89
+ script = next((a for a in argv[1:] if not a.startswith("-")), argv[1])
90
+ if Path(script).name == "main.py" and "comfyui" in " ".join(argv[:2]).lower():
91
+ return "ComfyUI"
92
+ return Path(script).name
93
+ if program in ("llama-server", "ollama") or "/ollama/" in (argv[0] if argv else ""):
94
+ return "Ollama"
95
+ return program or process
96
+
97
+
49
98
  def _linux_ram_gib() -> float:
50
99
  try:
51
100
  with open("/proc/meminfo") as f: