loki-mode 11.5.1 → 11.6.0

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 (98) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/loki +12 -201
  4. package/autonomy/notification-checker.py +1 -1
  5. package/dashboard/__init__.py +3 -10
  6. package/dashboard/control.py +5 -435
  7. package/docs/ARCHITECTURE.md +1 -2
  8. package/docs/CLI-CORE-VERBS.md +2 -6
  9. package/docs/CLI-REFERENCE.md +1 -1
  10. package/docs/COMPONENTS.md +0 -2
  11. package/docs/INSTALLATION.md +1 -1
  12. package/docs/authentication.md +19 -1
  13. package/docs/dev/release-checklist.md +9 -8
  14. package/docs/enterprise/security.md +3 -234
  15. package/docs/v10/ARCHITECT-CUTS.md +304 -0
  16. package/docs/v10/DECISIONS.md +5 -5
  17. package/docs/v10/ENGINE.md +735 -299
  18. package/docs/v10/GUARDS.md +16 -14
  19. package/docs/v10/GUIDE.md +5 -7
  20. package/docs/v10/PROGRESS.md +12 -1
  21. package/docs/v11/MARKET-SLICES.md +1 -5
  22. package/integrations/openclaw/README.md +20 -0
  23. package/integrations/vibe-kanban.md +12 -50
  24. package/loki-ts/dist/loki.js +1183 -1182
  25. package/mcp/__init__.py +1 -1
  26. package/mcp/_sdk_loader.py +1 -1
  27. package/package.json +2 -2
  28. package/packages/control-plane/dist/server.js +630 -613
  29. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  30. package/references/quality-control.md +1 -116
  31. package/skills/00-index.md +2 -2
  32. package/skills/artifacts.md +0 -22
  33. package/skills/production.md +2 -38
  34. package/web-app/dist/assets/{AdminPage-Cbu3pXL8.js → AdminPage-DhXdJNQk.js} +1 -1
  35. package/web-app/dist/assets/{Avatar-DGqGGcGx.js → Avatar-ixVj76fM.js} +1 -1
  36. package/web-app/dist/assets/{Badge-Bhlipt6v.js → Badge-BGMSp22s.js} +1 -1
  37. package/web-app/dist/assets/{Button-CpN2sO61.js → Button-pYJc32tG.js} +1 -1
  38. package/web-app/dist/assets/{CockpitPage-BqeDJwdL.js → CockpitPage-C1JBBouA.js} +1 -1
  39. package/web-app/dist/assets/{ComparePage-DUieA2ba.js → ComparePage-qD0NV4RK.js} +1 -1
  40. package/web-app/dist/assets/{ErrorBoundary-DTWsYrOm.js → ErrorBoundary-C-yxO58j.js} +1 -1
  41. package/web-app/dist/assets/{EvidenceReceiptPanel-BU_B9X19.js → EvidenceReceiptPanel-ByPzuE1S.js} +1 -1
  42. package/web-app/dist/assets/{GitHubIssuesPanel-DEZoLOsP.js → GitHubIssuesPanel-BNv_2BEJ.js} +1 -1
  43. package/web-app/dist/assets/{GitHubPRsPanel-BEsnrq7Y.js → GitHubPRsPanel-CuLZQ9CS.js} +1 -1
  44. package/web-app/dist/assets/{HomePage-BoUVuq7h.js → HomePage-CS_FW8Je.js} +2 -2
  45. package/web-app/dist/assets/{LoginPage-CmOED7vb.js → LoginPage-DwiNf1Wm.js} +1 -1
  46. package/web-app/dist/assets/{MagicPage-DATZitrZ.js → MagicPage-CmQybLPZ.js} +1 -1
  47. package/web-app/dist/assets/{MetricsPage-DGL1v0I-.js → MetricsPage-D9ERdpv8.js} +1 -1
  48. package/web-app/dist/assets/{NotFoundPage-C2WgOjZd.js → NotFoundPage-D9ccgdbF.js} +1 -1
  49. package/web-app/dist/assets/{ProjectPage-BMi1tepj.js → ProjectPage-B9Jslmgv.js} +3 -3
  50. package/web-app/dist/assets/{ProjectsPage-vc3y5YPh.js → ProjectsPage-DnU99Go2.js} +1 -1
  51. package/web-app/dist/assets/{SettingsPage-kbq0Ftvi.js → SettingsPage-DcTyx6wo.js} +1 -1
  52. package/web-app/dist/assets/{ShowcasePage-Bn6Q8Kbg.js → ShowcasePage-jEY9ghSr.js} +1 -1
  53. package/web-app/dist/assets/{SystemSettingsPage-Basmhs_b.js → SystemSettingsPage-CSGltW-8.js} +1 -1
  54. package/web-app/dist/assets/{TeamsPage-BTqOc4TR.js → TeamsPage-gUuJXb9l.js} +1 -1
  55. package/web-app/dist/assets/{TemplatesPage-2P9002VL.js → TemplatesPage-37Zhe--v.js} +1 -1
  56. package/web-app/dist/assets/{TerminalOutput-CAoSPBrg.js → TerminalOutput-B09hRwaR.js} +1 -1
  57. package/web-app/dist/assets/{activity-BcWVWCqU.js → activity-q_4MY9J0.js} +1 -1
  58. package/web-app/dist/assets/{bell-CYRqqgZ6.js → bell-X8OC_PFP.js} +1 -1
  59. package/web-app/dist/assets/{bot-CU7gdn3g.js → bot-C-N1PUOD.js} +1 -1
  60. package/web-app/dist/assets/{check-DLlCpz9V.js → check-B2c76Jmp.js} +1 -1
  61. package/web-app/dist/assets/{chevron-left-CE9Cb30C.js → chevron-left-BF76YLNw.js} +1 -1
  62. package/web-app/dist/assets/{circle-alert-uou4bjua.js → circle-alert-AeFKBD8h.js} +1 -1
  63. package/web-app/dist/assets/{clock-C_dSJcDX.js → clock-CiXRf-FH.js} +1 -1
  64. package/web-app/dist/assets/{cloud-DZ22ITF6.js → cloud-DKQ8SRJ5.js} +1 -1
  65. package/web-app/dist/assets/{code-xml-BrJS0hhS.js → code-xml-DEb6jXWP.js} +1 -1
  66. package/web-app/dist/assets/{database-D2HOmxtl.js → database-6W7e-E9c.js} +1 -1
  67. package/web-app/dist/assets/{dollar-sign-CQ1vK_6q.js → dollar-sign-Ds2GOuyW.js} +1 -1
  68. package/web-app/dist/assets/{file-code-corner-w2vpGm5d.js → file-code-corner-CZU0jg52.js} +1 -1
  69. package/web-app/dist/assets/{file-plus-DlF6wjkD.js → file-plus-DTVYnXCN.js} +1 -1
  70. package/web-app/dist/assets/{globe-Dy3lBJg1.js → globe-0mUzKYDe.js} +1 -1
  71. package/web-app/dist/assets/{hammer-C3xIiRXN.js → hammer-BMHZg3YX.js} +1 -1
  72. package/web-app/dist/assets/{index-4t-_IW2y.js → index-BvOTvjax.js} +3 -3
  73. package/web-app/dist/assets/{layers-Y8Fs8qXI.js → layers-Df7TdcWB.js} +1 -1
  74. package/web-app/dist/assets/{loader-circle-CxgN1v4m.js → loader-circle-kPsVfrSY.js} +1 -1
  75. package/web-app/dist/assets/{lock-DFFNbXDs.js → lock-CXYcbEc5.js} +1 -1
  76. package/web-app/dist/assets/{package-5e6qCTUg.js → package-Cqhua1ID.js} +1 -1
  77. package/web-app/dist/assets/{plus-C0Go_ytj.js → plus-lseXhsn-.js} +1 -1
  78. package/web-app/dist/assets/{refresh-cw-D4i-NW3o.js → refresh-cw-OZriI6gD.js} +1 -1
  79. package/web-app/dist/assets/{rotate-ccw-YlKkiUW6.js → rotate-ccw-CKCfjPg8.js} +1 -1
  80. package/web-app/dist/assets/{scroll-text-4qXOHTap.js → scroll-text-DoVyyfKb.js} +1 -1
  81. package/web-app/dist/assets/{server-BB6zXNp9.js → server-DGy7TflW.js} +1 -1
  82. package/web-app/dist/assets/{shield-alert-D4tzjB1H.js → shield-alert-BCzRcMXi.js} +1 -1
  83. package/web-app/dist/assets/{thumbs-up-DZiRwdFj.js → thumbs-up-C_znJd5g.js} +1 -1
  84. package/web-app/dist/assets/{trash-2-Dv_LkRIK.js → trash-2-BosCbeeA.js} +1 -1
  85. package/web-app/dist/assets/{trending-down-BJYp9PQe.js → trending-down-CkR5zDkV.js} +1 -1
  86. package/web-app/dist/assets/{trending-up-BTcXLklK.js → trending-up-DpUIfOH4.js} +1 -1
  87. package/web-app/dist/assets/{upload-fcHqwOxr.js → upload-CH9aKc8L.js} +1 -1
  88. package/web-app/dist/assets/{usePolling-BeJYw_4L.js → usePolling-pzxrHJeg.js} +1 -1
  89. package/web-app/dist/assets/{user-BcDwUCsO.js → user-B7OHa-VQ.js} +1 -1
  90. package/web-app/dist/index.html +1 -1
  91. package/dashboard/run.py +0 -63
  92. package/docs/openclaw-integration.md +0 -52
  93. package/docs/v10/HANDOFF-NEXT-WEEK.md +0 -40
  94. package/docs/v10/MORNING-BRIEF-1003.md +0 -25
  95. package/docs/v10/MORNING-BRIEF.md +0 -52
  96. package/docs/v10/TODO.md +0 -35
  97. package/mcp/resources.py +0 -351
  98. package/mcp/tools.py +0 -200
@@ -1,62 +1,23 @@
1
1
  """
2
- Loki Mode Session Control API
2
+ Loki Mode session-control helpers
3
3
 
4
- FastAPI-based session control endpoints for the Loki Mode dashboard.
5
- Provides start/stop/pause/resume functionality and real-time status updates.
6
-
7
- Usage:
8
- uvicorn dashboard.control:app --host 0.0.0.0 --port 57374
9
- # Or run with the CLI:
10
- loki dashboard start
4
+ Shared helpers for the dashboard: session status, atomic JSON writes, skill-dir
5
+ discovery and the browser-mutation Origin check. The HTTP control routes live
6
+ in dashboard/server.py (the only dashboard app).
11
7
  """
12
8
 
13
- import asyncio
14
9
  import fcntl
15
10
  import json
16
11
  import os
17
- import signal
18
- import subprocess
19
12
  import tempfile
20
13
  from datetime import datetime, timezone
21
14
  from pathlib import Path
22
15
  from typing import Optional
23
16
  from urllib.parse import urlsplit
24
17
 
25
- from fastapi import Depends, FastAPI, HTTPException, Request
26
- from fastapi.middleware.cors import CORSMiddleware
27
- from fastapi.responses import JSONResponse, StreamingResponse
18
+ from fastapi import Request
28
19
  from pydantic import BaseModel
29
20
 
30
- # Auth gating for the standalone control app.
31
- #
32
- # This module also defines a self-contained FastAPI `app` whose own docstring
33
- # invites operators to expose it via `uvicorn dashboard.control:app`. When that
34
- # happens the state-mutating endpoints (start/stop/pause/resume) MUST honor the
35
- # same scope checks as the primary dashboard (dashboard/server.py), otherwise a
36
- # user who follows the docstring stands up an unauthenticated control plane that
37
- # can launch arbitrary builds and kill running sessions even when
38
- # LOKI_ENTERPRISE_AUTH / OIDC are configured.
39
- #
40
- # auth.require_scope is a no-op (allows access) when no auth method is enabled,
41
- # so this import is safe for the default anonymous-localhost workflow and only
42
- # enforces when the operator has explicitly turned auth on. The import is
43
- # defensive: if the package context is unavailable (e.g. the file is run from a
44
- # path where the relative import fails) we fall back to a gate that always
45
- # allows, preserving the prior behavior rather than crashing import.
46
- try:
47
- from . import auth as _auth
48
-
49
- def _require_control_scope():
50
- return Depends(_auth.require_scope("control"))
51
- except Exception: # pragma: no cover - defensive fallback for non-package runs
52
- def _require_control_scope():
53
- async def _noop() -> bool:
54
- return True
55
-
56
- return Depends(_noop)
57
-
58
- _CONTROL_DEP = _require_control_scope()
59
-
60
21
 
61
22
  def _normalized_http_origin(value: str) -> tuple[str, str, int] | None:
62
23
  """Return a comparable browser origin, or ``None`` when malformed.
@@ -250,104 +211,6 @@ def atomic_write_json(file_path: Path, data: dict, use_lock: bool = True):
250
211
  except Exception as e:
251
212
  raise RuntimeError(f"Failed to write {file_path}: {e}")
252
213
 
253
- # FastAPI app
254
- app = FastAPI(
255
- title="Loki Mode Control API",
256
- description="Session control endpoints for Loki Mode dashboard",
257
- version="1.0.0"
258
- )
259
-
260
- # CORS middleware for dashboard frontend - restricted to localhost by default.
261
- # Set LOKI_DASHBOARD_CORS to override (comma-separated origins).
262
- _cors_default = "http://localhost:57374,http://127.0.0.1:57374"
263
- _cors_raw = os.environ.get("LOKI_DASHBOARD_CORS", _cors_default)
264
- _cors_origins = [o.strip() for o in _cors_raw.split(",") if o.strip()]
265
- if "*" in _cors_origins or _cors_raw.strip() == "*":
266
- if os.environ.get("LOKI_ENV") == "production":
267
- raise RuntimeError(
268
- "Wildcard CORS ('*') is not allowed in production. "
269
- "Set LOKI_DASHBOARD_CORS to a specific origin list, "
270
- "or set LOKI_ENV != production."
271
- )
272
- import logging
273
-
274
- logging.getLogger(__name__).warning(
275
- "LOKI_DASHBOARD_CORS is set to '*' -- all origins are allowed. "
276
- "This is insecure for production deployments."
277
- )
278
- app.add_middleware(
279
- CORSMiddleware,
280
- allow_origins=_cors_origins,
281
- allow_credentials=True,
282
- allow_methods=["*"],
283
- allow_headers=["*"],
284
- )
285
-
286
-
287
- @app.middleware("http")
288
- async def browser_mutation_boundary(request: Request, call_next):
289
- """Refuse cross-origin browser mutations before control side effects."""
290
- if request.method in ("POST", "PUT", "PATCH", "DELETE"):
291
- if not browser_mutation_origin_allowed(request, _cors_origins):
292
- return JSONResponse(
293
- status_code=403,
294
- content={"detail": "cross-origin mutation refused"},
295
- )
296
- return await call_next(request)
297
-
298
-
299
- # Request/Response models
300
- class StartRequest(BaseModel):
301
- """Request body for starting a Loki Mode session."""
302
- prd: Optional[str] = None
303
- provider: str = "claude"
304
- parallel: bool = False
305
- background: bool = True
306
-
307
- def validate_provider(self) -> None:
308
- """Validate provider is from allowed list."""
309
- allowed_providers = ["claude", "codex", "gemini", "cline", "aider"]
310
- if self.provider not in allowed_providers:
311
- raise ValueError(f"Invalid provider: {self.provider}. Must be one of: {', '.join(allowed_providers)}")
312
-
313
- def validate_prd_path(self) -> None:
314
- """Validate PRD path is safe and exists."""
315
- if not self.prd:
316
- return
317
-
318
- # Check for path traversal sequences
319
- if ".." in self.prd:
320
- raise ValueError("PRD path contains path traversal sequence (..)")
321
-
322
- # Resolve to absolute path and verify it exists
323
- prd_path = Path(self.prd).resolve()
324
- if not prd_path.exists():
325
- raise ValueError(f"PRD file does not exist: {self.prd}")
326
-
327
- # Verify it's a file, not a directory
328
- if not prd_path.is_file():
329
- raise ValueError(f"PRD path is not a file: {self.prd}")
330
-
331
- # Verify path resolves within CWD or a reasonable parent.
332
- # FAIL CLOSED if the cwd is gone: this is a path-confinement check, so
333
- # an unresolvable base must reject the path, never skip the comparison.
334
- try:
335
- cwd = Path.cwd().resolve()
336
- except OSError as exc:
337
- raise ValueError(
338
- "cannot validate PRD path: the working directory no longer "
339
- "exists (%s)" % exc
340
- ) from exc
341
- try:
342
- prd_path.relative_to(cwd)
343
- except ValueError:
344
- # Not within CWD - check if it's within user's home or project directory
345
- home = Path.home().resolve()
346
- try:
347
- prd_path.relative_to(home)
348
- except ValueError:
349
- raise ValueError(f"PRD path is outside allowed directories: {self.prd}")
350
-
351
214
 
352
215
  class StatusResponse(BaseModel):
353
216
  """Current session status."""
@@ -365,13 +228,6 @@ class StatusResponse(BaseModel):
365
228
  timestamp: str
366
229
 
367
230
 
368
- class ControlResponse(BaseModel):
369
- """Generic control operation response."""
370
- success: bool
371
- message: str
372
- pid: Optional[int] = None
373
-
374
-
375
231
  # Utility functions
376
232
  def read_file_safe(filepath: Path) -> str:
377
233
  """Read file contents safely, returning empty string on error."""
@@ -520,289 +376,3 @@ def get_status() -> StatusResponse:
520
376
  complexity=complexity,
521
377
  timestamp=datetime.now(timezone.utc).isoformat()
522
378
  )
523
-
524
-
525
- # API Endpoints
526
- @app.get("/api/control/health")
527
- async def health_check():
528
- """Health check endpoint."""
529
- return {"status": "ok", "version": get_version()}
530
-
531
-
532
- @app.get("/api/control/status", response_model=StatusResponse)
533
- async def get_session_status():
534
- """Get current session status."""
535
- return get_status()
536
-
537
-
538
- @app.post("/api/control/start", response_model=ControlResponse, dependencies=[_CONTROL_DEP])
539
- async def start_session(request: StartRequest):
540
- """
541
- Start a Loki Mode session.
542
-
543
- Args:
544
- request: Start request with PRD path, provider, and options
545
-
546
- Returns:
547
- ControlResponse with success status and PID
548
- """
549
- # Validate input
550
- try:
551
- request.validate_provider()
552
- request.validate_prd_path()
553
- except ValueError as e:
554
- raise HTTPException(status_code=400, detail=str(e))
555
-
556
- # Check if already running
557
- status = get_status()
558
- if status.state == "running":
559
- raise HTTPException(
560
- status_code=409,
561
- detail=f"Session already running with PID {status.pid}"
562
- )
563
-
564
- # Verify run.sh exists
565
- if not RUN_SH.exists():
566
- raise HTTPException(
567
- status_code=500,
568
- detail=f"run.sh not found at {RUN_SH}"
569
- )
570
-
571
- # Build command arguments
572
- args = [str(RUN_SH), "--provider", request.provider]
573
- if request.parallel:
574
- args.append("--parallel")
575
- if request.background:
576
- args.append("--bg")
577
- if request.prd:
578
- args.append(request.prd)
579
-
580
- try:
581
- # Start the process
582
- # RUN_SH is a trusted fixed path; provider and PRD were validated above,
583
- # and argv is passed directly without a command shell.
584
- process = subprocess.Popen(
585
- args, # lgtm[py/command-line-injection]
586
- stdout=subprocess.DEVNULL,
587
- stderr=subprocess.DEVNULL,
588
- start_new_session=True,
589
- # A deleted cwd would make Popen itself raise; fall back to the
590
- # skill tree rather than failing to launch the run at all.
591
- cwd=str(_cwd_or_skill_dir()),
592
- shell=False,
593
- )
594
-
595
- # Save provider for status tracking
596
- (STATE_DIR / "provider").write_text(request.provider)
597
-
598
- # Emit start event
599
- emit_event("session_start", {
600
- "pid": process.pid,
601
- "provider": request.provider,
602
- "prd": request.prd,
603
- "parallel": request.parallel
604
- })
605
-
606
- return ControlResponse(
607
- success=True,
608
- message=f"Session started with provider {request.provider}",
609
- pid=process.pid
610
- )
611
- except Exception as e:
612
- raise HTTPException(status_code=500, detail=str(e))
613
-
614
-
615
- @app.post("/api/control/stop", response_model=ControlResponse, dependencies=[_CONTROL_DEP])
616
- async def stop_session():
617
- """
618
- Stop the current Loki Mode session.
619
-
620
- Creates a STOP file to signal graceful shutdown and attempts
621
- to terminate the process directly.
622
- """
623
- stop_file = LOKI_DIR / "STOP"
624
- pid_file = LOKI_DIR / "loki.pid"
625
-
626
- # Create STOP file for graceful shutdown
627
- stop_file.parent.mkdir(parents=True, exist_ok=True)
628
- stop_file.write_text(datetime.now(timezone.utc).isoformat())
629
-
630
- # Also try to terminate process directly
631
- pid_str = read_file_safe(pid_file)
632
- pid = None
633
- if pid_str.isdigit():
634
- pid = int(pid_str)
635
- if is_process_running(pid):
636
- try:
637
- os.kill(pid, signal.SIGTERM)
638
- except (OSError, ProcessLookupError):
639
- pass
640
-
641
- # Mark session.json as stopped (skill-invoked sessions)
642
- session_file = LOKI_DIR / "session.json"
643
- if session_file.exists():
644
- try:
645
- # Read current session data
646
- session_data = json.loads(session_file.read_text())
647
- session_data["status"] = "stopped"
648
-
649
- # Atomic write with file locking to prevent race conditions
650
- atomic_write_json(session_file, session_data, use_lock=True)
651
- except (json.JSONDecodeError, OSError, KeyError, RuntimeError):
652
- pass
653
-
654
- # Emit stop event
655
- emit_event("session_stop", {"pid": pid, "reason": "user_request"})
656
-
657
- return ControlResponse(
658
- success=True,
659
- message="Stop signal sent",
660
- pid=pid
661
- )
662
-
663
-
664
- @app.post("/api/control/pause", response_model=ControlResponse, dependencies=[_CONTROL_DEP])
665
- async def pause_session():
666
- """
667
- Pause the current Loki Mode session.
668
-
669
- Creates a PAUSE file that signals the runner to pause
670
- after completing the current task.
671
- """
672
- pause_file = LOKI_DIR / "PAUSE"
673
-
674
- # Create PAUSE file
675
- pause_file.parent.mkdir(parents=True, exist_ok=True)
676
- pause_file.write_text(datetime.now(timezone.utc).isoformat())
677
-
678
- # Get current PID for response
679
- pid_file = LOKI_DIR / "loki.pid"
680
- pid_str = read_file_safe(pid_file)
681
- pid = int(pid_str) if pid_str.isdigit() else None
682
-
683
- # Emit pause event
684
- emit_event("session_pause", {"pid": pid})
685
-
686
- return ControlResponse(
687
- success=True,
688
- message="Pause signal sent - session will pause after current task",
689
- pid=pid
690
- )
691
-
692
-
693
- @app.post("/api/control/resume", response_model=ControlResponse, dependencies=[_CONTROL_DEP])
694
- async def resume_session():
695
- """
696
- Resume a paused Loki Mode session.
697
-
698
- Removes the PAUSE and STOP files to allow the session to continue.
699
- """
700
- pause_file = LOKI_DIR / "PAUSE"
701
- stop_file = LOKI_DIR / "STOP"
702
-
703
- # Remove control files
704
- try:
705
- pause_file.unlink(missing_ok=True)
706
- except Exception:
707
- pass
708
-
709
- try:
710
- stop_file.unlink(missing_ok=True)
711
- except Exception:
712
- pass
713
-
714
- # Get current PID for response
715
- pid_file = LOKI_DIR / "loki.pid"
716
- pid_str = read_file_safe(pid_file)
717
- pid = int(pid_str) if pid_str.isdigit() else None
718
-
719
- # Emit resume event
720
- emit_event("session_resume", {"pid": pid})
721
-
722
- return ControlResponse(
723
- success=True,
724
- message="Session resumed",
725
- pid=pid
726
- )
727
-
728
-
729
- @app.get("/api/control/events")
730
- async def stream_events():
731
- """
732
- Stream events as Server-Sent Events (SSE).
733
-
734
- Provides real-time updates to the dashboard frontend.
735
- """
736
- async def event_generator():
737
- # Send initial status
738
- status = get_status()
739
- yield f"data: {json.dumps(status.model_dump())}\n\n"
740
-
741
- # Track file position for incremental reads
742
- last_position = 0
743
- if EVENTS_FILE.exists():
744
- last_position = EVENTS_FILE.stat().st_size
745
-
746
- # Stream updates
747
- while True:
748
- # Send status update every 2 seconds
749
- status = get_status()
750
- yield f"event: status\ndata: {json.dumps(status.model_dump())}\n\n"
751
-
752
- # Check for new events
753
- if EVENTS_FILE.exists():
754
- current_size = EVENTS_FILE.stat().st_size
755
- if current_size > last_position:
756
- with open(EVENTS_FILE, "r") as f:
757
- f.seek(last_position)
758
- for line in f:
759
- line = line.strip()
760
- if line:
761
- yield f"event: log\ndata: {line}\n\n"
762
- last_position = current_size
763
-
764
- await asyncio_sleep(2)
765
-
766
- return StreamingResponse(
767
- event_generator(),
768
- media_type="text/event-stream",
769
- headers={
770
- "Cache-Control": "no-cache",
771
- "Connection": "keep-alive"
772
- }
773
- )
774
-
775
-
776
- @app.get("/api/control/logs")
777
- async def get_logs(lines: int = 50):
778
- """
779
- Get recent log lines from the session log.
780
-
781
- Args:
782
- lines: Number of lines to return (default 50, max 10000)
783
- """
784
- lines = min(max(lines, 1), 10000)
785
- log_file = LOG_DIR / "session.log"
786
-
787
- if not log_file.exists():
788
- return {"logs": [], "total": 0}
789
-
790
- content = log_file.read_text()
791
- all_lines = [line for line in content.split("\n") if line.strip()]
792
- recent_lines = all_lines[-lines:]
793
-
794
- return {"logs": recent_lines, "total": len(all_lines)}
795
-
796
-
797
- # Helper for async sleep
798
- async def asyncio_sleep(seconds: float):
799
- """Async sleep helper."""
800
- await asyncio.sleep(seconds)
801
-
802
-
803
- # Run with uvicorn if executed directly
804
- if __name__ == "__main__":
805
- import uvicorn
806
- port = int(os.environ.get("LOKI_DASHBOARD_PORT", "57374"))
807
- host = os.environ.get("LOKI_DASHBOARD_HOST", "127.0.0.1")
808
- uvicorn.run(app, host=host, port=port)
@@ -215,8 +215,7 @@ memory/ Memory system (Python package, ~19 modules)
215
215
 
216
216
  mcp/ Model Context Protocol server
217
217
  server.py MCP server (tools + resources + prompts)
218
- tools.py / magic_tools.py / managed_tools.py Tool registries
219
- resources.py MCP resources
218
+ magic_tools.py / managed_tools.py Tool registries
220
219
  lsp_proxy.py LSP proxy (references, definitions, symbols)
221
220
 
222
221
  dashboard/ FastAPI control-plane backend
@@ -98,12 +98,8 @@ The process exit code equals `exit_code`.
98
98
  | 3 | Missing component, or verifier error |
99
99
  | 64 | Usage error for `verify`, `quick` and `start` (unknown option, missing task) |
100
100
 
101
- Severity rises with the code. `loki verify` exits 0 VERIFIED, 1 CONCERNS, 2
102
- BLOCKED or not a git directory, 3 verifier error or empty diff, 64 usage error.
103
- Gate CI with `loki verify || fail` and treat any code of 2 or higher as worse
104
- than CONCERNS. From 11.4.0 this is a breaking change for scripts that tested
105
- `rc == 1` on an empty diff or a non-git directory. Per-command detail:
106
- `docs/exit-codes.md`.
101
+ Severity rises with the code. `loki verify` codes and the CI-gate guidance are
102
+ in `docs/exit-codes.md`.
107
103
 
108
104
  ## Unknown commands
109
105
 
@@ -1,6 +1,6 @@
1
1
  # CLI reference
2
2
 
3
- Generated from `loki-ts/src/cli/registry.ts` by `scripts/generate-stale-zero.sh` for v11.5.1. Do not edit by hand.
3
+ Generated from `loki-ts/src/cli/registry.ts` by `scripts/generate-stale-zero.sh` for v11.6.0. Do not edit by hand.
4
4
  Hidden and legacy-only commands are omitted; see `docs/v10/CLI-MODERN.md` for the full inventory.
5
5
 
6
6
  | Command | Description |
@@ -249,13 +249,11 @@ search) to MCP clients.
249
249
  **Key files:**
250
250
  - `server.py` - MCP server (47 tools: 31 in-file + magic + gated managed + 8 cp; plus
251
251
  3 resources, 2 prompts).
252
- - `tools.py` - Core tool implementations.
253
252
  - `magic_tools.py` - Magic Modules tools.
254
253
  - `cp_tools.py` - Read-only Control Plane data tools (`cp_*`, GET only; the CP URL
255
254
  and token come from the MCP child env and are never returned).
256
255
  - `managed_tools.py` - Managed-memory tool (`loki_memory_redact`, gated on
257
256
  `LOKI_MANAGED_AGENTS=true` and `LOKI_MANAGED_MEMORY=true`).
258
- - `resources.py` - MCP resources.
259
257
  - `lsp_proxy.py` - LSP proxy (find references, go to definition, symbol lookup).
260
258
  - `learning_collector.py` - Learning signal collection.
261
259
  - `_sdk_loader.py` - Bootstraps the Python MCP SDK on first run.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Loki Mode, by [Autonomi](https://www.autonomi.dev/), turns a spec or an issue into a verified pull request with a receipt you can check. This page covers installing it, a first run, and the options around it.
4
4
 
5
- **Version:** v11.5.1
5
+ **Version:** v11.6.0
6
6
 
7
7
  **Engine note:** `loki start` is the primary command. `loki start`, `loki "<task>"`, `loki owner/repo#N` and `loki quick` all run the Loki 10 engine, whatever the flag order or input form (PRD file, issue ref, task or one-word brief). The previous loop runs only on `--engine legacy`, `LOKI_ENGINE=legacy`, or for one call when a flag Loki 10 cannot honor is present. See the [user guide](v10/GUIDE.md) and the [5-minute quickstart](QUICKSTART.md).
8
8
 
@@ -97,6 +97,20 @@ Scope hierarchy:
97
97
  - `control` includes `write` and `read`
98
98
  - `write` includes `read`
99
99
 
100
+ ### Key Rotation and Revocation
101
+
102
+ Dashboard API keys (`/api/keys`) can be rotated with a grace period during which the old key stays valid (default 24 hours, `grace_period_hours`):
103
+
104
+ ```bash
105
+ curl -X POST http://localhost:57374/api/keys/ci-pipeline/rotate \
106
+ -H "Authorization: Bearer $ADMIN_TOKEN" \
107
+ -H "Content-Type: application/json" \
108
+ -d '{"grace_period_hours": 24}'
109
+
110
+ curl -X DELETE http://localhost:57374/api/keys/ci-pipeline \
111
+ -H "Authorization: Bearer $ADMIN_TOKEN"
112
+ ```
113
+
100
114
  ### Roles
101
115
 
102
116
  Predefined roles map to common access patterns:
@@ -177,7 +191,11 @@ Running with signature verification off provides no authentication security.
177
191
  4. Provider redirects back with JWT
178
192
  5. Dashboard validates JWT and grants access
179
193
 
180
- OIDC-authenticated users receive full access scopes by default. For fine-grained control, combine OIDC with token-based authorization.
194
+ OIDC-authenticated users are NOT granted full access by default. The role is resolved from claims (see below) and its scopes are enforced through the same hierarchy as API tokens.
195
+
196
+ ### OIDC Role Claims
197
+
198
+ Role claims are read case-insensitively; values may be a string, a space-separated string or a list. Sources: the claim named by `LOKI_OIDC_ROLES_CLAIM` (dotted paths such as `realm_access.roles` work), then `roles`, `groups`, `realm_access.roles` (Keycloak) and `cognito:groups` (AWS Cognito). Only values that exactly match a built-in role name (`admin`, `operator`, `viewer`, `auditor`) grant that role; other group names fall through to `LOKI_OIDC_DEFAULT_ROLE`. When several roles match, the highest privilege wins (`admin` > `operator` > `auditor` > `viewer`). An unset or unrecognized default falls back to `viewer`, never `admin`. When PyJWT and cryptography are installed, the signature (RS256/RS384/RS512), issuer, audience and expiry are verified against the issuer JWKS.
181
199
 
182
200
  ### Mixed Mode
183
201
 
@@ -4,9 +4,10 @@ Moved out of CLAUDE.md (S-78) to keep the root file short. Updated in this
4
4
  pass to remove two items that `docs/v10/DECISIONS.md` D25 and
5
5
  `docs/LOKI-10-BUILD-PROMPT.md` section 1 have superseded:
6
6
  - `git add -A` in step 4 is replaced with staging by name (repo rule, always).
7
- - Per-merge pushing is replaced by the release-train model (D25): batch
8
- approved merges locally, push once per train, freeze main until Tests, Bun
9
- Parity and Security Audit are all green on that exact SHA, then release.
7
+ - Per-merge pushing and the D25 release trains are superseded by D96 (every
8
+ approved slice is a release; see `docs/v10/OPERATING-MODEL.md`). Waiting for
9
+ Tests and Security Audit green on that exact SHA still applies to any push
10
+ made outside the merge-gate.
10
11
  "Wait for user approval before commit" from the old workflow is superseded
11
12
  by the standing authorization in `docs/LOKI-10-BUILD-PROMPT.md` section 1
12
13
  for sessions operating under that program; outside it, ask as normal.
@@ -116,13 +117,13 @@ rm -f loki-mode-*.tgz
116
117
  ```
117
118
  If any check fails, do not release; fix the root cause first.
118
119
 
119
- ### 4. Commit and land (release-train model, D25)
120
+ ### 4. Commit and land (every approved slice is a release, D96)
120
121
 
121
122
  Stage files by name (never `git add -A` or `git add .`), commit with the
122
- repo-local `asklokesh` identity, no co-author. Batch approved merges locally;
123
- push once per train (`git push origin main`); wait for Tests and
124
- Security Audit to go green on that exact SHA before bumping VERSION and
125
- releasing. GitHub Actions then creates the tag, the GitHub Release, publishes
123
+ repo-local `asklokesh` identity, no co-author. The merge-gate merges approved
124
+ slices to main and main publishes to npm `next` (D96); for a manual push
125
+ (`git push origin main`), wait for Tests and Security Audit to go green on that
126
+ exact SHA before bumping VERSION and releasing. GitHub Actions then creates the tag, the GitHub Release, publishes
126
127
  npm, builds/pushes Docker, and updates the Homebrew tap. Do not manually
127
128
  create tags.
128
129