loki-mode 7.87.0 → 7.89.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.
@@ -1,12 +1,14 @@
1
1
  """Anonymous usage telemetry for Loki Mode dashboard.
2
2
 
3
- Collection is OPT-IN and OFF by default. Nothing is sent unless the user
4
- explicitly opts in, so a default install (including air-gapped, GDPR, and
5
- FedRAMP deployments) never phones home.
3
+ Collection is ON BY DEFAULT for an ordinary individual install, and AUTO-OFF in
4
+ enterprise / CI / air-gapped / non-interactive contexts (see _auto_off), so those
5
+ deployments stay silent out of the box (GDPR / FedRAMP safe). Only anonymous
6
+ diagnostics are ever sent; never code, prompts, paths, keys, or repo names. The
7
+ gate mirrors autonomy/telemetry.sh + autonomy/crash.sh exactly.
6
8
 
7
- Opt-in (one required): LOKI_TELEMETRY=on OR ~/.loki/config: TELEMETRY_ENABLED=true
8
9
  Opt-out (always wins): LOKI_TELEMETRY=off / LOKI_TELEMETRY_DISABLED=true /
9
10
  DO_NOT_TRACK=1 / ~/.loki/config: TELEMETRY_DISABLED=true
11
+ Force-on: LOKI_TELEMETRY=on OR ~/.loki/config: TELEMETRY_ENABLED=true
10
12
 
11
13
  All calls are fire-and-forget, silent on failure, non-blocking.
12
14
  """
@@ -14,6 +16,7 @@ All calls are fire-and-forget, silent on failure, non-blocking.
14
16
  import json
15
17
  import os
16
18
  import platform
19
+ import sys
17
20
  import threading
18
21
  import uuid
19
22
  from pathlib import Path
@@ -25,17 +28,57 @@ _POSTHOG_HOST = os.environ.get(
25
28
  _POSTHOG_KEY = "phc_ya0vGBru41AJWtGNfZZ8H9W4yjoZy4KON0nnayS7s87"
26
29
 
27
30
 
31
+ def _auto_off():
32
+ """Enterprise / CI / air-gapped / non-interactive detection: contexts where
33
+ on-by-default would be inappropriate, so collection auto-disables and stays
34
+ silent out of the box. MUST stay in sync with _loki_telemetry_auto_off
35
+ (autonomy/telemetry.sh) and _loki_collection_auto_off (autonomy/crash.sh)."""
36
+ if os.environ.get("CI") == "true":
37
+ return True
38
+ for var in ("GITHUB_ACTIONS", "GITLAB_CI", "BUILDKITE", "JENKINS_URL",
39
+ "TEAMCITY_VERSION"):
40
+ if os.environ.get(var):
41
+ return True
42
+ if os.environ.get("CONTINUOUS_INTEGRATION") == "true":
43
+ return True
44
+ if os.environ.get("LOKI_ENTERPRISE") == "true":
45
+ return True
46
+ if os.environ.get("LOKI_AIRGAP") == "true":
47
+ return True
48
+ # Non-interactive detection (council cH_r1 AC2). Interactivity is resolved
49
+ # exactly once at the real entry point (bin/loki shim / autonomy/loki main)
50
+ # and exported as LOKI_TTY_INTERACTIVE. Trust that explicit signal instead of
51
+ # a fresh isatty() probe, because the gate can run in a detached/non-TTY
52
+ # context (backgrounded thread / subprocess) where isatty() would wrongly
53
+ # auto-off a real interactive user. Fall back to a live isatty() probe only
54
+ # when the signal is unset (the helper ran without passing an entry point).
55
+ # MUST match _loki_telemetry_auto_off (telemetry.sh) and
56
+ # _loki_collection_auto_off (crash.sh).
57
+ tty_signal = os.environ.get("LOKI_TTY_INTERACTIVE")
58
+ if tty_signal is not None and tty_signal != "":
59
+ return tty_signal != "1"
60
+ # Non-interactive: neither stdout nor stdin is a terminal (scripts/pipes/
61
+ # detached/containers). An individual user at a real shell has a TTY.
62
+ try:
63
+ if not sys.stdout.isatty() and not sys.stdin.isatty():
64
+ return True
65
+ except Exception:
66
+ pass
67
+ return False
68
+
69
+
28
70
  def _is_enabled():
29
- # Unified OPT-IN gate. Collection is OFF by default; enabled ONLY when the
30
- # user has opted in AND has not also opted out. This precedence MUST mirror
31
- # loki_collection_enabled in autonomy/crash.sh and _loki_telemetry_enabled
32
- # in autonomy/telemetry.sh so one model gates BOTH PostHog usage telemetry
33
- # and crash reporting.
71
+ # Unified gate. Default ON for individual interactive installs; auto-OFF in
72
+ # enterprise/CI/air-gapped contexts; explicit opt-out always wins. Precedence
73
+ # MUST mirror loki_collection_enabled in autonomy/crash.sh and
74
+ # _loki_telemetry_enabled in autonomy/telemetry.sh so one model gates BOTH
75
+ # PostHog usage telemetry and crash reporting.
34
76
  #
35
77
  # Precedence:
36
- # 1. Any opt-out flag present -> False (hard kill, always wins)
37
- # 2. Else any opt-in flag present -> True
38
- # 3. Else (default) -> False (no egress)
78
+ # 1. Any opt-out flag present -> False (hard kill, always wins)
79
+ # 2. Else explicit opt-in present -> True (force-on, even in CI/enterprise)
80
+ # 3. Else enterprise/CI/air-gapped -> False (auto-off, safe out of the box)
81
+ # 4. Else (individual default) -> True (anonymous diagnostics)
39
82
  telem = os.environ.get("LOKI_TELEMETRY", "").lower()
40
83
 
41
84
  # --- 1. Opt-out always wins ---
@@ -59,14 +102,18 @@ def _is_enabled():
59
102
  except Exception:
60
103
  pass
61
104
 
62
- # --- 2. Opt-in required to enable ---
105
+ # --- 2. Explicit opt-in forces ON (overrides the enterprise/CI auto-off) ---
63
106
  if telem == "on":
64
107
  return True
65
108
  if config_enabled:
66
109
  return True
67
110
 
68
- # --- 3. Default: OFF ---
69
- return False
111
+ # --- 3. Enterprise / CI / air-gapped: auto-off (safe out of the box) ---
112
+ if _auto_off():
113
+ return False
114
+
115
+ # --- 4. Individual interactive default: ON (anonymous diagnostics) ---
116
+ return True
70
117
 
71
118
 
72
119
  def _get_distinct_id():
@@ -2,7 +2,7 @@
2
2
 
3
3
  The flagship product of [Autonomi](https://www.autonomi.dev/). Loki Mode is a spec-driven autonomous builder with a built-in trust layer that takes any spec to a deployed product and verifies completion with evidence (quality gates plus a completion council), not just a "done" claim. Complete installation instructions for all platforms and use cases.
4
4
 
5
- **Version:** v7.87.0
5
+ **Version:** v7.89.0
6
6
 
7
7
  ---
8
8
 
@@ -395,7 +395,7 @@ provider works inside the container. Provide auth with your Anthropic API key:
395
395
  # Run Loki Mode in Docker (Claude provider, API-key auth)
396
396
  docker run --rm -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
397
397
  -v $(pwd):/workspace -w /workspace \
398
- asklokesh/loki-mode:7.87.0 start ./my-spec.md
398
+ asklokesh/loki-mode:7.89.0 start ./my-spec.md
399
399
  ```
400
400
 
401
401
  ##### docker compose + .env (no host install)
package/docs/PRIVACY.md CHANGED
@@ -6,21 +6,32 @@ match the code, the code is the bug; please open an issue.
6
6
 
7
7
  ## Summary
8
8
 
9
- - Anonymous diagnostics are OPT-IN and OFF by default. A default install sends
10
- no telemetry or diagnostics of any kind. This covers a default `npm install`,
11
- the CLI (session and command events), the dashboard, and the welcome page
12
- form. Air-gapped, GDPR, and FedRAMP deployments are safe out of the box: an
13
- untouched install sends us no telemetry or diagnostics. (This statement scopes
14
- to telemetry and diagnostics; provider CLIs you configure, such as Claude or
15
- Codex, make their own network calls under your own credentials and are
16
- governed by their vendors.)
17
- - When you DO opt in, Loki Mode collects anonymous diagnostics to help find and
18
- fix bugs. It NEVER collects your code, prompts, PRDs, file paths, environment
19
- values, API keys, repository names, emails, or IP addresses.
9
+ - Anonymous diagnostics are ON BY DEFAULT for an ordinary individual install,
10
+ and AUTO-OFF in enterprise, CI, and air-gapped contexts. This covers the CLI
11
+ (session and command events), the dashboard, and the welcome page form. What is
12
+ ever sent is ONLY anonymous diagnostics (operating system, architecture, Loki
13
+ version, error type, and sanitized stack signatures). It NEVER includes your
14
+ code, prompts, PRDs, file paths, environment values, API keys, repository
15
+ names, emails, or IP addresses. (This statement scopes to telemetry and
16
+ diagnostics; provider CLIs you configure, such as Claude or Codex, make their
17
+ own network calls under your own credentials and are governed by their vendors.)
18
+ - Enterprise / CI / air-gapped deployments are safe out of the box: collection
19
+ AUTO-DISABLES (no opt-out needed) when any of these is detected -- CI
20
+ (CI/GITHUB_ACTIONS/GITLAB_CI/BUILDKITE/JENKINS_URL/TEAMCITY_VERSION/
21
+ CONTINUOUS_INTEGRATION), an enterprise/air-gapped marker
22
+ (LOKI_ENTERPRISE=true / LOKI_AIRGAP=true), or a non-interactive session (no
23
+ TTY: scripts, pipes, cron, detached/container runs). In those contexts an
24
+ untouched install sends us nothing. GDPR / FedRAMP deployments stay clean.
25
+ - Disclosure is never covert: the first-run welcome screen states (once) that
26
+ anonymous diagnostics are on and how to turn them off, and this document is the
27
+ canonical reference.
28
+ - Opt out anytime, and opt-out ALWAYS wins: `loki telemetry off` /
29
+ `LOKI_TELEMETRY=off` / `LOKI_TELEMETRY_DISABLED=true` / `DO_NOT_TRACK=1` /
30
+ `~/.loki/config: TELEMETRY_DISABLED=true`. Conversely `loki telemetry on`
31
+ force-enables even inside CI/enterprise if you want to send us diagnostics.
20
32
  - Crash reporting (Phase 0) is local-only with zero network egress regardless,
21
- and is also gated by opt-in, so a default install writes nothing at all.
22
- - You opt in with a single switch (`loki telemetry on` or `LOKI_TELEMETRY=on`)
23
- and can opt back out at any time. Opt-out always wins over opt-in.
33
+ and is gated by the same switch, so an opted-out (or auto-off) install writes
34
+ nothing at all.
24
35
 
25
36
  ## Two collection paths exist
26
37
 
@@ -46,10 +57,14 @@ Phase 0 behavior:
46
57
  GitHub issue URL so you can submit it manually if you choose. Loki Mode does
47
58
  not submit anything for you in this version.
48
59
 
49
- ### 2. Usage telemetry (anonymous, opt-in)
60
+ ### 2. Usage telemetry (anonymous, on by default for individuals)
50
61
 
51
- Loki Mode can send anonymous usage telemetry via PostHog, but ONLY after you opt
52
- in. By default it is OFF and nothing is sent.
62
+ Loki Mode sends anonymous usage telemetry via PostHog. It is ON by default for an
63
+ ordinary individual install, and AUTO-OFF in enterprise, CI, air-gapped, and
64
+ non-interactive contexts (see the precedence below). It is gated by the same
65
+ switch as crash reporting, so a single opt-out (`loki telemetry off` /
66
+ `DO_NOT_TRACK=1`) disables everything, and it never sends your code, prompts,
67
+ paths, keys, or repo names -- only anonymous diagnostics.
53
68
 
54
69
  - Endpoint: `https://us.i.posthog.com/capture/` (override with
55
70
  `LOKI_TELEMETRY_ENDPOINT`). The PostHog project key is a public ingest key.
@@ -115,36 +130,45 @@ prompts, briefs, and diffs can never reach the payload even if a redaction rule
115
130
  were to miss something. Secrets are additionally scrubbed by the shared redactor
116
131
  before whitelisting.
117
132
 
118
- ## How to opt in (and opt back out)
133
+ ## How to turn it off (and force it on)
119
134
 
120
- Collection is OFF by default. To turn it on, use ANY one of:
135
+ Anonymous diagnostics are ON by default for an ordinary individual install. To
136
+ turn them off at any time, use ANY one of the following. Opt-out always wins, so
137
+ setting one of these guarantees nothing is collected or sent:
121
138
 
122
- - Run `loki telemetry on` (persists `TELEMETRY_ENABLED=true` to `~/.loki/config`)
123
- - Set the environment variable `LOKI_TELEMETRY=on` (exact word `on`,
124
- case-insensitive; values like `1` or `true` do NOT count as consent)
125
-
126
- To opt back out at any time, use ANY one of the following. Opt-out always wins
127
- over opt-in, so setting one of these guarantees nothing is collected or sent:
128
-
129
- - Run `loki telemetry off`
139
+ - Run `loki telemetry off` (persists `TELEMETRY_DISABLED=true` to `~/.loki/config`)
130
140
  - Set `LOKI_TELEMETRY=off`
131
141
  - Set `DO_NOT_TRACK=1` (the cross-tool community convention)
132
142
  - Set `LOKI_TELEMETRY_DISABLED=true`
133
143
 
144
+ To FORCE it on (for example to send us diagnostics from a context that would
145
+ otherwise auto-disable, like CI), use ANY one of:
146
+
147
+ - Run `loki telemetry on` (persists `TELEMETRY_ENABLED=true` to `~/.loki/config`)
148
+ - Set `LOKI_TELEMETRY=on` (exact word `on`, case-insensitive)
149
+
134
150
  ### Precedence (exact)
135
151
 
136
152
  1. If any opt-out flag is set, collection is OFF (hard kill, always wins).
137
- 2. Else if any opt-in flag is set, collection is ON.
138
- 3. Otherwise (the default), collection is OFF.
153
+ 2. Else if an explicit opt-in (`loki telemetry on` / `LOKI_TELEMETRY=on` /
154
+ `TELEMETRY_ENABLED=true`) is set, collection is ON (this overrides the
155
+ enterprise/CI/air-gapped auto-off below).
156
+ 3. Else if the context is enterprise / CI / air-gapped / non-interactive,
157
+ collection is OFF (auto-off, safe out of the box). Detected via: CI /
158
+ GITHUB_ACTIONS / GITLAB_CI / BUILDKITE / JENKINS_URL / TEAMCITY_VERSION /
159
+ CONTINUOUS_INTEGRATION, or LOKI_ENTERPRISE=true / LOKI_AIRGAP=true, or no TTY.
160
+ 4. Otherwise (an ordinary individual install), collection is ON.
161
+
162
+ In all enabled cases, if `curl` is unavailable there is no egress.
139
163
 
140
164
  ### Air-gapped and enterprise deployments
141
165
 
142
- Because collection is opt-in, a default install in an air-gapped, GDPR, or
143
- FedRAMP environment sends us no telemetry or diagnostics: there is nothing to
144
- turn off because there is nothing on. To make opting in impossible by accident
145
- across a fleet, bake `LOKI_TELEMETRY_DISABLED=true` (or `DO_NOT_TRACK=1`) into
146
- your base image or CI environment; opt-out always wins regardless of any later
147
- opt-in.
166
+ A default install in an air-gapped, CI, or non-interactive environment sends us
167
+ no telemetry or diagnostics: collection AUTO-DISABLES there (step 3 above), so
168
+ there is nothing to turn off. To make collection impossible across a fleet
169
+ regardless of context, bake `LOKI_TELEMETRY_DISABLED=true` (or `DO_NOT_TRACK=1`)
170
+ into your base image or CI environment; opt-out always wins over everything,
171
+ including a stray `loki telemetry on`.
148
172
 
149
173
  This same gate covers ALL paths: the `npm install` event, CLI session and
150
174
  command events, the dashboard event, the welcome form, and local crash capture.
@@ -183,9 +207,12 @@ that choice plainly so you can decide whether to opt out.
183
207
 
184
208
  ## Compliance posture
185
209
 
186
- - Opt-in by default: nothing is collected or sent unless the user explicitly
187
- opts in. A default install (including air-gapped) sends us no telemetry or
188
- diagnostics.
210
+ - Safe-by-default for enterprise: collection AUTO-DISABLES in enterprise, CI,
211
+ air-gapped, and non-interactive contexts, so an untouched install in those
212
+ environments sends us no telemetry or diagnostics (no action required). For an
213
+ ordinary individual install it is on by default (anonymous diagnostics only),
214
+ disclosed once on first use, and a single opt-out (`loki telemetry off` /
215
+ `DO_NOT_TRACK=1`) always wins and disables everything.
189
216
  - Anonymous by design: no PII is in the whitelist; emails and IP addresses are
190
217
  denied outright. The welcome form's role / company-size / tools fields are
191
218
  self-reported and anonymous (no name, email, or IP).