@simplexai/localmodels-win32-x64 0.1.0-dev.103 → 0.1.0-dev.105

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 (172) hide show
  1. package/LICENSE +201 -0
  2. package/{modules/simplex_localmodels-0.1.0.dev103.dist-info/licenses/NOTICE → NOTICE} +42 -13
  3. package/README.md +10 -0
  4. package/bootstrap.identity +1 -1
  5. package/bootstrap.sha256 +159 -158
  6. package/modules/localmodels/__init__.py +1 -1
  7. package/modules/localmodels/__main__.py +204 -86
  8. package/modules/localmodels/apple_sensors.py +23 -0
  9. package/modules/localmodels/approval.py +25 -2
  10. package/modules/localmodels/catalog.json +584 -158
  11. package/modules/localmodels/catalog.py +18 -3
  12. package/modules/localmodels/catalog_recipes.py +64 -6
  13. package/modules/localmodels/cli_help.py +10 -0
  14. package/modules/localmodels/cli_parser.py +313 -230
  15. package/modules/localmodels/component.py +21 -3
  16. package/modules/localmodels/console.py +1 -1
  17. package/modules/localmodels/context_policy.py +6 -5
  18. package/modules/localmodels/custom_probe.py +4 -2
  19. package/modules/localmodels/debug_cli.py +0 -12
  20. package/modules/localmodels/debug_mode.py +0 -6
  21. package/modules/localmodels/decode_calibration.json +3 -4
  22. package/modules/localmodels/decode_calibration.py +5 -2
  23. package/modules/localmodels/deploy.py +11 -1
  24. package/modules/localmodels/deployment_lifecycle.py +1 -1
  25. package/modules/localmodels/download-mirrors.json +1 -1
  26. package/modules/localmodels/engine_adapters/base.py +11 -1
  27. package/modules/localmodels/engine_adapters/strata_poly.py +65 -3
  28. package/modules/localmodels/engine_adapters/suite_plan.py +61 -24
  29. package/modules/localmodels/engines-b11583.json +6 -26
  30. package/modules/localmodels/engines-b12588-mix-c0c3de8.json +3 -15
  31. package/modules/localmodels/engines-b12757-mix-ef2df21.json +3 -15
  32. package/modules/localmodels/engines-prism-b12178-03ec600.json +3 -15
  33. package/modules/localmodels/engines-speechcpp-v0.11.3.json +4 -20
  34. package/modules/localmodels/engines-strata-0.1.47.json +1 -5
  35. package/modules/localmodels/engines-strata-0.1.49.2.json +1 -5
  36. package/modules/localmodels/engines-strata-0.1.59.1.json +1 -5
  37. package/modules/localmodels/engines-strata-poly-0.2.20-poly.1.json +6 -30
  38. package/modules/localmodels/engines-strata-poly-0.2.20-poly.9.json +129 -0
  39. package/modules/localmodels/engines-whisper-b5454.json +6 -30
  40. package/modules/localmodels/engines.json +13 -61
  41. package/modules/localmodels/estimator.py +10 -5
  42. package/modules/localmodels/gpu_specs.py +1 -1
  43. package/modules/localmodels/host_sensors.py +25 -2
  44. package/modules/localmodels/hosts.py +38 -21
  45. package/modules/localmodels/kokoro-tts-0.6.1.txt +1 -1
  46. package/modules/localmodels/library_cli.py +34 -16
  47. package/modules/localmodels/library_custom.py +9 -1
  48. package/modules/localmodels/library_direct.py +41 -1
  49. package/modules/localmodels/library_elastic.py +135 -6
  50. package/modules/localmodels/library_jobs.py +23 -4
  51. package/modules/localmodels/library_kept.py +9 -1
  52. package/modules/localmodels/library_model.py +174 -2
  53. package/modules/localmodels/library_order.py +175 -69
  54. package/modules/localmodels/library_poly.py +150 -21
  55. package/modules/localmodels/library_presentation.py +485 -0
  56. package/modules/localmodels/library_pricing.py +15 -4
  57. package/modules/localmodels/library_serve.py +342 -70
  58. package/modules/localmodels/library_smoke.py +63 -5
  59. package/modules/localmodels/library_state.py +48 -10
  60. package/modules/localmodels/library_status.py +37 -17
  61. package/modules/localmodels/llm_rank.py +22 -11
  62. package/modules/localmodels/metal.py +1 -2
  63. package/modules/localmodels/plan_envelope.py +40 -13
  64. package/modules/localmodels/planning/budget.py +14 -12
  65. package/modules/localmodels/planning/memory_pools.py +7 -1
  66. package/modules/localmodels/privacy_acceptance.py +6 -5
  67. package/modules/localmodels/probe.py +34 -7
  68. package/modules/localmodels/py.typed +0 -0
  69. package/modules/localmodels/quant_formats.py +10 -3
  70. package/modules/localmodels/recommend_cli.py +1 -1
  71. package/modules/localmodels/records.py +19 -2
  72. package/modules/localmodels/remote_ops_launchd.py +8 -1
  73. package/modules/localmodels/remote_ops_verify.py +91 -24
  74. package/modules/localmodels/runtime_index.py +303 -0
  75. package/modules/localmodels/runtime_process.py +1 -1
  76. package/modules/localmodels/service_deployment.py +2 -4
  77. package/modules/localmodels/service_probe.py +59 -13
  78. package/modules/localmodels/setup_inspection.py +94 -73
  79. package/modules/localmodels/setup_text.py +7 -56
  80. package/modules/localmodels/sidecar_downloads.py +34 -0
  81. package/modules/localmodels/sidecar_http.py +61 -5
  82. package/modules/localmodels/sidecar_state.py +52 -2
  83. package/modules/localmodels/speech_admission.py +20 -4
  84. package/modules/localmodels/speech_catalog.py +23 -0
  85. package/modules/localmodels/speech_cli.py +30 -16
  86. package/modules/localmodels/speech_jobs.py +42 -17
  87. package/modules/localmodels/speech_serve.py +9 -2
  88. package/modules/localmodels/speech_server.py +185 -81
  89. package/modules/localmodels/speech_state.py +4 -1
  90. package/modules/localmodels/speech_workers.py +11 -0
  91. package/modules/localmodels/stack.py +1 -1
  92. package/modules/localmodels/stack_args.py +276 -145
  93. package/modules/localmodels/stack_auto.py +91 -6
  94. package/modules/localmodels/stack_aux_gpu.py +1 -1
  95. package/modules/localmodels/stack_cleanup.py +21 -18
  96. package/modules/localmodels/stack_cli.py +120 -115
  97. package/modules/localmodels/stack_compose.py +16 -5
  98. package/modules/localmodels/stack_debug.py +15 -6
  99. package/modules/localmodels/stack_decision.py +4 -4
  100. package/modules/localmodels/stack_doctor.py +2 -2
  101. package/modules/localmodels/stack_down.py +2 -0
  102. package/modules/localmodels/stack_events.py +1 -1
  103. package/modules/localmodels/stack_gpu_memory.py +1 -1
  104. package/modules/localmodels/stack_hardware.py +17 -15
  105. package/modules/localmodels/stack_mcp.py +1 -2
  106. package/modules/localmodels/stack_mlx.py +8 -1
  107. package/modules/localmodels/stack_picks.py +20 -21
  108. package/modules/localmodels/stack_plan.py +12 -11
  109. package/modules/localmodels/stack_ports.py +31 -4
  110. package/modules/localmodels/stack_review.py +28 -7
  111. package/modules/localmodels/stack_rollback.py +1 -1
  112. package/modules/localmodels/stack_run.py +1 -1
  113. package/modules/localmodels/stack_suite.py +72 -21
  114. package/modules/localmodels/stack_up.py +2 -0
  115. package/modules/localmodels/stack_view.py +180 -35
  116. package/modules/localmodels/stack_view_agent.py +1 -1
  117. package/modules/localmodels/stack_view_demo.py +2 -0
  118. package/modules/localmodels/stack_view_gpu.py +36 -2
  119. package/modules/localmodels/stack_view_schema.py +26 -3
  120. package/modules/localmodels/stack_view_serve.py +0 -2
  121. package/modules/localmodels/stack_view_slots.py +3 -1
  122. package/modules/localmodels/stack_view_telemetry.py +90 -4
  123. package/modules/localmodels/stack_view_tick.py +246 -40
  124. package/modules/localmodels/stack_view_words.py +9 -2
  125. package/modules/localmodels/stack_warm.py +2 -2
  126. package/modules/localmodels/stack_whatif.py +524 -41
  127. package/modules/localmodels/stack_whatif_html.py +900 -0
  128. package/modules/localmodels/startlux-decide-83fe6c7d.txt +2 -2
  129. package/modules/localmodels/{strata-poly-serve-0.2.20-poly.7.txt → strata-poly-serve-0.2.20-poly.9.txt} +1 -1
  130. package/modules/localmodels/strata_poly_server.py +114 -3
  131. package/modules/localmodels/suite.py +265 -6
  132. package/modules/localmodels/telemetry_math.py +458 -18
  133. package/modules/localmodels/transport.py +8 -1
  134. package/modules/localmodels/tts_admission.py +2 -17
  135. package/modules/localmodels/tts_catalog.py +29 -1
  136. package/modules/localmodels/tts_cli.py +45 -22
  137. package/modules/localmodels/tts_http.py +10 -4
  138. package/modules/localmodels/tts_jobs.py +49 -19
  139. package/modules/localmodels/tts_serve.py +9 -2
  140. package/modules/localmodels/tts_server.py +1 -1
  141. package/modules/localmodels/tts_sidecar.py +69 -28
  142. package/modules/localmodels/tts_state.py +7 -2
  143. package/modules/localmodels/vision.py +5 -3
  144. package/modules/localmodels/web/view/ASSET-SOURCES.md +4 -7
  145. package/modules/localmodels/web/view/view.css +0 -1
  146. package/modules/localmodels/web/view/view.js +2 -5
  147. package/modules/localmodels/web/whatif/app.js +730 -0
  148. package/modules/localmodels/web/whatif/page.html +1172 -0
  149. package/modules/localmodels/web/whatif/sim.js +297 -0
  150. package/modules/localmodels/win_probe.py +89 -16
  151. package/modules/localmodels/windows_job.py +179 -11
  152. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/METADATA +14 -0
  153. package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/RECORD +151 -145
  154. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/LICENSE +201 -0
  155. package/modules/simplex_localmodels-0.1.0.dev105.dist-info/licenses/NOTICE +126 -0
  156. package/package.json +11 -2
  157. package/tool.json +1 -1
  158. package/modules/localmodels/engines-strata-poly-0.2.20-poly.7.json +0 -94
  159. package/modules/localmodels/fixtures/stack-research-demo-plan.json +0 -1059
  160. package/modules/localmodels/stack_research.py +0 -716
  161. package/modules/localmodels/stack_research_demo.py +0 -125
  162. package/modules/localmodels/stack_research_plan.py +0 -146
  163. package/modules/localmodels/web/index.html +0 -2605
  164. package/modules/localmodels/web/sizecalc/app.js +0 -1306
  165. package/modules/localmodels/web/sizecalc/calc.js +0 -269
  166. package/modules/localmodels/web/sizecalc/page.html +0 -520
  167. package/modules/localmodels/web/view/logo-claude.svg +0 -3
  168. package/modules/localmodels/web/view/logo-codex.png +0 -0
  169. package/modules/simplex_localmodels-0.1.0.dev103.dist-info/METADATA +0 -9
  170. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/WHEEL +0 -0
  171. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/entry_points.txt +0 -0
  172. /package/modules/{simplex_localmodels-0.1.0.dev103.dist-info → simplex_localmodels-0.1.0.dev105.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -8,37 +8,15 @@ grouped by purpose, so ``stack plan --help`` scans as model choice, placement, s
8
8
  from __future__ import annotations
9
9
 
10
10
  import argparse
11
+ from collections.abc import Callable
11
12
  from pathlib import Path
12
- from typing import TypeAlias
13
-
14
- from localmodels import (
15
- cli_help,
16
- deploy,
17
- stack_arena,
18
- stack_card,
19
- stack_debug,
20
- stack_down,
21
- stack_ledger,
22
- stack_mcp,
23
- stack_memory,
24
- stack_ports,
25
- stack_rollback,
26
- stack_suite,
27
- stack_try,
28
- stack_up,
29
- stack_update,
30
- stack_view_agent,
31
- stack_view_hub_cli,
32
- stack_view_serve,
33
- stack_warm,
34
- stack_whatif,
35
- vision,
36
- )
37
- from localmodels import stack_decision as decide
38
- from localmodels import stack_doctor as day2
39
- from localmodels import stack_hardware as hardware
40
- from localmodels.context_policy import AGENT, window_k
41
- from localmodels.stack_plan import PREFERENCES, REASONING_BUDGET, StackOptions
13
+ from types import ModuleType
14
+ from typing import TYPE_CHECKING, TypeAlias
15
+
16
+ from localmodels import cli_help
17
+
18
+ if TYPE_CHECKING:
19
+ from localmodels.stack_plan import StackOptions
42
20
 
43
21
  Parsers: TypeAlias = "argparse._SubParsersAction[argparse.ArgumentParser]"
44
22
 
@@ -66,7 +44,7 @@ GROUPS = (
66
44
  )
67
45
  STACK = """\
68
46
  Plan, install and run the local agent stack on this computer: the smartest LLM that fits,
69
- a gateway (Bifrost by default) and the pi agent. A GPU decision model, embedding/reranker/STT
47
+ served locally over loopback OpenAI-compatible endpoints. A GPU decision model, embedding/reranker/STT
70
48
  and TTS are optional and off by default (--decision, --aux, --tts).
71
49
  Nothing is downloaded or started until you approve a saved plan.
72
50
 
@@ -103,6 +81,8 @@ EXIT = (
103
81
 
104
82
  def _tokens(value: str) -> int:
105
83
  """A token count such as 65536, 64K or 128k (K is 1024)."""
84
+ from localmodels.context_policy import AGENT, window_k
85
+
106
86
  text = value.strip().lower()
107
87
  try:
108
88
  tokens = int(text[:-1]) * 1024 if text.endswith("k") else int(text)
@@ -135,6 +115,9 @@ def _budget(value: str) -> int:
135
115
 
136
116
  def options_from_args(args: argparse.Namespace) -> StackOptions:
137
117
  """The plan options every planning front-end shares (`stack plan`, `install`, the TUI)."""
118
+ from localmodels import stack_debug, stack_suite, vision
119
+ from localmodels import stack_hardware as hardware
120
+
138
121
  options: StackOptions = {
139
122
  "llm": args.llm,
140
123
  "decision": args.decision,
@@ -174,6 +157,11 @@ def options_from_args(args: argparse.Namespace) -> StackOptions:
174
157
 
175
158
  def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
176
159
  """The planning options `stack plan` and `install` share; plan-only extras stay with `plan`."""
160
+ from localmodels import deploy, stack_ports, stack_suite, vision
161
+ from localmodels import stack_decision as decide
162
+ from localmodels import stack_hardware as hardware
163
+ from localmodels.stack_plan import PREFERENCES, REASONING_BUDGET
164
+
177
165
  choose = plan.add_argument_group("what to install")
178
166
  choose.add_argument(
179
167
  "--llm",
@@ -186,7 +174,7 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
186
174
  "--prefer",
187
175
  choices=PREFERENCES,
188
176
  default="smartest",
189
- help="what auto optimizes (roadmap decision 26): smartest, the highest installed "
177
+ help="what auto optimizes: smartest, the highest installed "
190
178
  "SimplexAI score that fits (default), except that a Mac of 16 GB or more takes its "
191
179
  "Spark-X2.6 ladder while no validated model scoring 50 fits, and Windows NVIDIA falls "
192
180
  "back to Spark-X2.6-4B Q8_0 when no validated model fits; concurrent, at least two "
@@ -199,7 +187,7 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
199
187
  "--route",
200
188
  choices=["none", "fastest"],
201
189
  action=cli_help.ComponentSelection,
202
- help="add the fastest LLM for easy turns (Bifrost and a decision model required)",
190
+ help="add the fastest LLM for easy turns (a decision model is required)",
203
191
  )
204
192
  decide.add_arguments(choose)
205
193
  stack_suite.add_arguments(choose)
@@ -207,7 +195,7 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
207
195
  "--vision",
208
196
  choices=vision.READERS,
209
197
  default=vision.DEFAULT,
210
- help="image input for an LLM that reads pictures (roadmap decision 31): auto puts the "
198
+ help="image input for an LLM that reads pictures: auto puts the "
211
199
  "picture reader on a GPU of 23.5 GiB or more and on the CPU below that (default); gpu, "
212
200
  "cpu, or off for text only",
213
201
  )
@@ -254,8 +242,8 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
254
242
  type=_budget,
255
243
  default=REASONING_BUDGET,
256
244
  metavar="TOKENS",
257
- help="the most tokens one reply may think before it must answer (default 8192, roadmap "
258
- "decision 37; 0 or off: no cap)",
245
+ help="the most tokens one reply may think before it must answer (default 8192, "
246
+ "0 or off: no cap)",
259
247
  )
260
248
  fit.add_argument(
261
249
  "--suite-memory",
@@ -330,6 +318,8 @@ def add_plan_arguments(plan: argparse.ArgumentParser) -> None:
330
318
 
331
319
 
332
320
  def _kv(text: str) -> str:
321
+ from localmodels import stack_debug
322
+
333
323
  try:
334
324
  return stack_debug.parse_kv(text)
335
325
  except ValueError as exc:
@@ -373,6 +363,8 @@ def document_install(parser: argparse.ArgumentParser, prog: str) -> None:
373
363
 
374
364
 
375
365
  def _plan(actions: Parsers) -> None:
366
+ from localmodels import stack_update
367
+
376
368
  plan = actions.add_parser("plan", help="price the whole stack for this computer, save a plan")
377
369
  add_plan_arguments(plan)
378
370
  out = plan.add_argument_group("input and output")
@@ -412,111 +404,224 @@ def _plan(actions: Parsers) -> None:
412
404
  )
413
405
 
414
406
 
415
- def _inspect(actions: Parsers) -> None:
416
- seen = actions.add_parser("hardware", help="each GPU, RAM, disk and what fits (read-only)")
417
- seen.add_argument(
418
- "--facts",
419
- type=Path,
420
- metavar="FILE",
421
- help="read host facts saved earlier instead of probing",
422
- )
423
- seen.add_argument("--json", action="store_true", help="print the readings as JSON")
424
- hardware.add_arguments(seen)
425
- stack_memory.add_parser(actions)
426
- stack_whatif.add_parser(actions)
427
- cli_help.document(
428
- seen,
429
- "Read-only: each GPU's model, VRAM (total, used, free, usable by the agent LLM), spec "
430
- "bandwidth, the processes holding it and the validated LLMs that fit it; then RAM, disk "
431
- "and the hardware tier. Priced the way `stack plan` prices them.",
432
- examples=[
433
- ("%(prog)s", "probe now"),
434
- ("%(prog)s --json", "the same readings as JSON"),
435
- ("%(prog)s --facts host.json", "another host's saved probe"),
436
- ],
437
- )
438
- listed = actions.add_parser("decisions", help="the decision models: VRAM, quality, pros, cons")
439
- cli_help.document(
440
- listed,
441
- "Read-only catalog view of the Jev-like decision models `--decision` accepts: VRAM per "
442
- "prompt limit, measured quality index, latency, license, pros and cons.",
443
- examples=[("%(prog)s", "")],
444
- )
407
+ def _inspect(actions: Parsers, only: str | None = None) -> None:
408
+ if only in (None, "hardware"):
409
+ from localmodels import stack_hardware as hardware
410
+
411
+ seen = actions.add_parser("hardware", help="each GPU, RAM, disk and what fits (read-only)")
412
+ seen.add_argument(
413
+ "--facts",
414
+ type=Path,
415
+ metavar="FILE",
416
+ help="read host facts saved earlier instead of probing",
417
+ )
418
+ seen.add_argument("--json", action="store_true", help="print the readings as JSON")
419
+ hardware.add_arguments(seen)
420
+ cli_help.document(
421
+ seen,
422
+ "Read-only: each GPU's model, VRAM (total, used, free, usable by the agent LLM), spec "
423
+ "bandwidth, the processes holding it and the validated LLMs that fit it; then RAM, disk "
424
+ "and the hardware tier. Priced the way `stack plan` prices them.",
425
+ examples=[
426
+ ("%(prog)s", "probe now"),
427
+ ("%(prog)s --json", "the same readings as JSON"),
428
+ ("%(prog)s --facts host.json", "another host's saved probe"),
429
+ ],
430
+ )
431
+ if only in (None, "memory"):
432
+ from localmodels import stack_memory
433
+
434
+ stack_memory.add_parser(actions)
435
+ if only in (None, "what-if"):
436
+ from localmodels import stack_whatif
437
+
438
+ stack_whatif.add_parser(actions)
439
+ if only in (None, "decisions"):
440
+ listed = actions.add_parser(
441
+ "decisions", help="the decision models: VRAM, quality, pros, cons"
442
+ )
443
+ cli_help.document(
444
+ listed,
445
+ "Read-only catalog view of the Jev-like decision models `--decision` accepts: VRAM per "
446
+ "prompt limit, measured quality index, latency, license, pros and cons.",
447
+ examples=[("%(prog)s", "")],
448
+ )
449
+
450
+
451
+ def _apply(actions: Parsers, only: str | None = None) -> None:
452
+ if only in (None, "apply"):
453
+ run = actions.add_parser("apply", help="install a saved plan you approved (live progress)")
454
+ run.add_argument("plan", type=Path, metavar="PLAN", help="the plan file `stack plan` saved")
455
+ run.add_argument(
456
+ "--approve", required=True, metavar="ID", help="the plan_id printed by stack plan"
457
+ )
458
+ output = run.add_mutually_exclusive_group()
459
+ output.add_argument(
460
+ "--json",
461
+ action="store_true",
462
+ help="one safe result on stdout; progress JSONL on stderr",
463
+ )
464
+ output.add_argument(
465
+ "--jsonl",
466
+ action="store_true",
467
+ help="sanitized progress counters and component results",
468
+ )
469
+ cli_help.document(
470
+ run,
471
+ "Install the plan you reviewed. Apply re-probes first and refuses when anything that "
472
+ "decided the plan changed (re-run `stack plan` then). On a terminal each component gets "
473
+ "a live row: download bar with speed and ETA, model loading, start and verification; "
474
+ "piped output is plain lines. Failed components stay visible; fix and rerun the same "
475
+ "command; files already downloaded are reused.",
476
+ examples=[
477
+ ("%(prog)s PLAN --approve ID", "the command `stack plan` printed"),
478
+ ("%(prog)s PLAN --approve ID --json", "installer protocol: one result object"),
479
+ ],
480
+ sections=[
481
+ ("output", "component verdicts on stdout; progress on stderr (JSONL with --json)"),
482
+ ("exit status", EXIT),
483
+ ],
484
+ )
485
+ if only in (None, "install"):
486
+ install = actions.add_parser("install", help="plan, confirm and apply in one command")
487
+ add_install_arguments(install)
488
+ document_install(install, "%(prog)s")
445
489
 
446
490
 
447
- def _apply(actions: Parsers) -> None:
448
- run = actions.add_parser("apply", help="install a saved plan you approved (live progress)")
449
- run.add_argument("plan", type=Path, metavar="PLAN", help="the plan file `stack plan` saved")
450
- run.add_argument(
451
- "--approve", required=True, metavar="ID", help="the plan_id printed by stack plan"
452
- )
453
- output = run.add_mutually_exclusive_group()
454
- output.add_argument(
455
- "--json", action="store_true", help="one safe result on stdout; progress JSONL on stderr"
456
- )
457
- output.add_argument(
458
- "--jsonl", action="store_true", help="sanitized progress counters and component results"
459
- )
460
- cli_help.document(
461
- run,
462
- "Install the plan you reviewed. Apply re-probes first and refuses when anything that "
463
- "decided the plan changed (re-run `stack plan` then). On a terminal each component gets "
464
- "a live row: download bar with speed and ETA, model loading, start and verification; "
465
- "piped output is plain lines. Failed components stay visible; fix and rerun the same "
466
- "command; files already downloaded are reused.",
467
- examples=[
468
- ("%(prog)s PLAN --approve ID", "the command `stack plan` printed"),
469
- ("%(prog)s PLAN --approve ID --json", "installer protocol: one result object"),
470
- ],
471
- sections=[
472
- ("output", "component verdicts on stdout; progress on stderr (JSONL with --json)"),
473
- ("exit status", EXIT),
474
- ],
475
- )
476
- install = actions.add_parser("install", help="plan, confirm and apply in one command")
477
- add_install_arguments(install)
478
- document_install(install, "%(prog)s")
491
+ def _helpers(actions: Parsers, only: str | None = None) -> None:
492
+ if only in (None, "capabilities"):
493
+ capabilities = actions.add_parser(
494
+ "capabilities", help="machine-readable protocol and feature support"
495
+ )
496
+ capabilities.add_argument(
497
+ "--json",
498
+ action="store_true",
499
+ required=True,
500
+ help="required: the output is JSON only",
501
+ )
502
+ cli_help.document(
503
+ capabilities,
504
+ "Installer feature detection: the package version and the stack features and schemas "
505
+ "this build implements (localmodels.stack-capabilities/v1). Reads no hardware.",
506
+ examples=[("%(prog)s --json", "")],
507
+ )
508
+ if only in (None, "commands"):
509
+ listing = actions.add_parser("commands", help="every stack subcommand and option (--json)")
510
+ listing.add_argument(
511
+ "--json", action="store_true", help="the tree as localmodels.cli-commands/v1"
512
+ )
513
+ cli_help.document(
514
+ listing,
515
+ "List every stack subcommand with its summary; --json adds usage, each option (flags, "
516
+ "value, default, choices, help) and the examples, for agents and completion scripts.",
517
+ examples=[("%(prog)s", "one line per command"), ("%(prog)s --json", "")],
518
+ )
519
+ if only in (None, "mcp"):
520
+ from localmodels import stack_mcp
479
521
 
522
+ stack_mcp.add_parser(actions)
480
523
 
481
- def _helpers(actions: Parsers) -> None:
482
- capabilities = actions.add_parser(
483
- "capabilities", help="machine-readable protocol and feature support"
484
- )
485
- capabilities.add_argument(
486
- "--json", action="store_true", required=True, help="required: the output is JSON only"
487
- )
488
- cli_help.document(
489
- capabilities,
490
- "Installer feature detection: the package version and the stack features and schemas "
491
- "this build implements (localmodels.stack-capabilities/v1). Reads no hardware.",
492
- examples=[("%(prog)s --json", "")],
493
- )
494
- listing = actions.add_parser("commands", help="every stack subcommand and option (--json)")
495
- listing.add_argument(
496
- "--json", action="store_true", help="the tree as localmodels.cli-commands/v1"
497
- )
498
- cli_help.document(
499
- listing,
500
- "List every stack subcommand with its summary; --json adds usage, each option (flags, "
501
- "value, default, choices, help) and the examples, for agents and completion scripts.",
502
- examples=[("%(prog)s", "one line per command"), ("%(prog)s --json", "")],
503
- )
504
- stack_mcp.add_parser(actions)
505
-
506
-
507
- def _day2(actions: Parsers) -> None:
508
- day2.add_parsers(actions)
509
- stack_up.add_parser(actions)
510
- stack_down.add_parser(actions)
511
- stack_warm.add_parser(actions)
512
- stack_try.add_parser(actions)
513
- stack_arena.add_parser(actions)
514
- stack_ledger.add_parser(actions)
515
- stack_card.add_parser(actions)
516
- stack_rollback.add_parser(actions)
517
- stack_view_serve.add_parser(actions)
518
- stack_view_hub_cli.add_parser(actions)
519
- stack_view_agent.add_parser(actions)
524
+
525
+ def _load_up() -> ModuleType:
526
+ from localmodels import stack_up
527
+
528
+ return stack_up
529
+
530
+
531
+ def _load_down() -> ModuleType:
532
+ from localmodels import stack_down
533
+
534
+ return stack_down
535
+
536
+
537
+ def _load_warm() -> ModuleType:
538
+ from localmodels import stack_warm
539
+
540
+ return stack_warm
541
+
542
+
543
+ def _load_try() -> ModuleType:
544
+ from localmodels import stack_try
545
+
546
+ return stack_try
547
+
548
+
549
+ def _load_arena() -> ModuleType:
550
+ from localmodels import stack_arena
551
+
552
+ return stack_arena
553
+
554
+
555
+ def _load_ledger() -> ModuleType:
556
+ from localmodels import stack_ledger
557
+
558
+ return stack_ledger
559
+
560
+
561
+ def _load_card() -> ModuleType:
562
+ from localmodels import stack_card
563
+
564
+ return stack_card
565
+
566
+
567
+ def _load_rollback() -> ModuleType:
568
+ from localmodels import stack_rollback
569
+
570
+ return stack_rollback
571
+
572
+
573
+ def _load_view() -> ModuleType:
574
+ from localmodels import stack_view_serve
575
+
576
+ return stack_view_serve
577
+
578
+
579
+ def _load_view_hub() -> ModuleType:
580
+ from localmodels import stack_view_hub_cli
581
+
582
+ return stack_view_hub_cli
583
+
584
+
585
+ def _load_view_agent() -> ModuleType:
586
+ from localmodels import stack_view_agent
587
+
588
+ return stack_view_agent
589
+
590
+
591
+ def _load_doctor() -> ModuleType:
592
+ from localmodels import stack_doctor
593
+
594
+ return stack_doctor
595
+
596
+
597
+ DAY2_LOADERS: dict[str, Callable[[], ModuleType]] = {
598
+ "up": _load_up,
599
+ "down": _load_down,
600
+ "warm": _load_warm,
601
+ "try": _load_try,
602
+ "arena": _load_arena,
603
+ "ledger": _load_ledger,
604
+ "card": _load_card,
605
+ "rollback": _load_rollback,
606
+ "view": _load_view,
607
+ "view-hub": _load_view_hub,
608
+ "view-agent": _load_view_agent,
609
+ }
610
+ DOCTOR_COMMANDS = frozenset({"status", "verify", "doctor", "remove", "prune"})
611
+
612
+
613
+ def day2_module(command_name: str) -> ModuleType:
614
+ """Lazily load the single day-2 handler module for ``command_name``."""
615
+ loader = DAY2_LOADERS.get(command_name, _load_doctor)
616
+ return loader()
617
+
618
+
619
+ def _day2(actions: Parsers, only: str | None = None) -> None:
620
+ if only is None or only in DOCTOR_COMMANDS:
621
+ _load_doctor().add_parsers(actions)
622
+ for name, loader in DAY2_LOADERS.items():
623
+ if only is None or only == name:
624
+ loader().add_parser(actions)
520
625
  docs = {
521
626
  "status": (
522
627
  "each deployment's state, health and disk, the last run (read-only)",
@@ -598,17 +703,43 @@ def _day2(actions: Parsers) -> None:
598
703
  ),
599
704
  }
600
705
  for name, (summary, description, examples) in docs.items():
601
- cli_help.summarize(actions, name, summary)
602
- cli_help.document(actions.choices[name], description, examples=examples)
706
+ if name in actions.choices:
707
+ cli_help.summarize(actions, name, summary)
708
+ cli_help.document(actions.choices[name], description, examples=examples)
709
+
710
+
711
+ _INSPECT_COMMANDS = frozenset({"hardware", "memory", "what-if", "decisions"})
712
+ _APPLY_COMMANDS = frozenset({"apply", "install"})
713
+ _HELPER_COMMANDS = frozenset({"capabilities", "commands", "mcp"})
714
+ _KNOWN_STACK_COMMANDS = (
715
+ frozenset({"plan"})
716
+ | _INSPECT_COMMANDS
717
+ | _APPLY_COMMANDS
718
+ | _HELPER_COMMANDS
719
+ | DOCTOR_COMMANDS
720
+ | frozenset(DAY2_LOADERS)
721
+ )
603
722
 
604
723
 
605
- def add_parser(sub: Parsers) -> None:
724
+ def add_parser(sub: Parsers, *, only: str | None = None) -> None:
606
725
  p = sub.add_parser("stack", help="the local agent stack: plan, install, operate, remove")
607
726
  actions = p.add_subparsers(dest="stack_command", required=True, metavar="COMMAND")
608
- _plan(actions)
609
- _inspect(actions)
610
- _apply(actions)
611
- _day2(actions)
612
- _helpers(actions)
727
+ target = only if only in _KNOWN_STACK_COMMANDS else None
728
+ if target is None:
729
+ _plan(actions)
730
+ _inspect(actions)
731
+ _apply(actions)
732
+ _day2(actions)
733
+ _helpers(actions)
734
+ elif target == "plan":
735
+ _plan(actions)
736
+ elif target in _INSPECT_COMMANDS:
737
+ _inspect(actions, only=target)
738
+ elif target in _APPLY_COMMANDS:
739
+ _apply(actions, only=target)
740
+ elif target in _HELPER_COMMANDS:
741
+ _helpers(actions, only=target)
742
+ else:
743
+ _day2(actions, only=target)
613
744
  cli_help.document(p, STACK, sections=[("for agents", AGENTS), ("exit status", EXIT)])
614
745
  cli_help.group_commands(p, GROUPS)