code-context-control 2.157.1__py3-none-any.whl → 2.157.2__py3-none-any.whl

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.
cli/_shell_writes.py CHANGED
@@ -33,7 +33,73 @@ _PY_WRITE_TEXT_RE = re.compile(r"""Path\(\s*(?P<q>['"])(?P<t>[^'"]+)(?P=q)\s*\)\
33
33
  _FILE_CMDS = {"cp", "mv", "touch", "rm", "install"}
34
34
  _STREAMS = {"/dev/null", "/dev/stdout", "/dev/stderr", "nul", "&1", "&2", "-"}
35
35
  _SYNTAX = set("$`(){}|<>*?")
36
+ _MSYS_DRIVE_RE = re.compile(r"^/([a-zA-Z])(?=/|$)")
37
+ _QUOTED_RES = (re.compile(r'"([^"\n]{1,400})"'), re.compile(r"'([^'\n]{1,400})'"))
36
38
  MAX_TARGETS = 20
39
+ MAX_QUOTED = 64
40
+
41
+
42
+ def msys_drive(path: str) -> str:
43
+ """`/c/x` -> `c:/x` on Windows, where Git Bash spells drives that way.
44
+
45
+ Without it `cd /u/repo` resolves to `<cwd drive>:/u/repo`, a directory
46
+ that does not exist, and every relative path after it is judged there.
47
+ """
48
+ if os.name != "nt" or not _MSYS_DRIVE_RE.match(path):
49
+ return path
50
+ return f"{path[1]}:/{path[3:]}"
51
+
52
+
53
+ def _shell_quoted(cmd: str) -> list[str]:
54
+ """Quoted strings as the shell reads them: `'` is literal inside `"`."""
55
+ out: list[str] = []
56
+ buf: list[str] = []
57
+ quote, esc = None, False
58
+ for ch in cmd:
59
+ if quote is None:
60
+ if esc:
61
+ esc = False
62
+ elif ch == "\\":
63
+ esc = True
64
+ elif ch in "'\"":
65
+ quote, buf = ch, []
66
+ elif quote == '"' and esc:
67
+ buf.append(ch)
68
+ esc = False
69
+ elif quote == '"' and ch == "\\":
70
+ buf.append(ch)
71
+ esc = True
72
+ elif ch == quote:
73
+ out.append("".join(buf))
74
+ quote = None
75
+ else:
76
+ buf.append(ch)
77
+ return out
78
+
79
+
80
+ def quoted_paths(cmd: str) -> list[str]:
81
+ """Path-shaped quoted substrings of a command, for the access scans.
82
+
83
+ A quoted path with spaces (`"U:/1. Projects/x/.env"`) splits into
84
+ fragments under a whitespace tokenizer, and quoted code
85
+ (`node -e "fs.readFileSync('x/.env')"`, a heredoc body) hides its
86
+ path inside a larger token. So this returns the shell's own quoted
87
+ strings plus the string literals inside them and anywhere in the text.
88
+ Over-collecting is expected: callers judge each candidate against files
89
+ that exist.
90
+ """
91
+ out: list[str] = []
92
+ cmd = cmd or ""
93
+ tops = _shell_quoted(cmd)
94
+ for s in tops + [m.group(1) for t in tops + [cmd]
95
+ for rx in _QUOTED_RES for m in rx.finditer(t)]:
96
+ s = s.strip()
97
+ if (s and "\n" not in s and len(s) <= 400 and s not in out
98
+ and ("/" in s or "\\" in s or s.startswith("."))):
99
+ out.append(s)
100
+ if len(out) >= MAX_QUOTED:
101
+ break
102
+ return out
37
103
 
38
104
 
39
105
  def _clean(tok: str) -> str:
@@ -79,7 +145,7 @@ def _cd_target(segment: str, cwd: str) -> str | None:
79
145
  m = _CD_RE.match(segment)
80
146
  if not m:
81
147
  return None
82
- target = m.group("dir").strip("\"'")
148
+ target = msys_drive(os.path.expanduser(m.group("dir").strip("\"'")))
83
149
  try:
84
150
  return target if os.path.isabs(target) else os.path.normpath(os.path.join(cwd, target))
85
151
  except (OSError, ValueError):
@@ -99,8 +165,7 @@ def shell_write_targets(cmd: str, cwd: str) -> list[str]:
99
165
  try:
100
166
  for segment in _SEGMENT_SPLIT.split(cmd or ""):
101
167
  for tok in _segment_targets(segment):
102
- if re.match(r"^/[a-z]/", tok): # MSYS /c/foo -> C:/foo
103
- tok = f"{tok[1]}:{tok[2:]}"
168
+ tok = msys_drive(os.path.expanduser(tok))
104
169
  try:
105
170
  p = Path(tok) if os.path.isabs(tok) else Path(here) / tok
106
171
  key = os.path.normcase(os.path.normpath(str(p)))
cli/c3.py CHANGED
@@ -91,7 +91,7 @@ console = Console() if HAS_RICH else None
91
91
  # Config
92
92
  CONFIG_DIR = ".c3"
93
93
  CONFIG_FILE = ".c3/config.json"
94
- __version__ = "2.157.1"
94
+ __version__ = "2.157.2"
95
95
 
96
96
  # The PreToolUse matcher for native subagent calls (installer and hub migration).
97
97
  AGENT_MATCHER = "Agent|Task"
cli/hook_access_guard.py CHANGED
@@ -34,13 +34,19 @@ except Exception: # pragma: no cover — telemetry is never load-bearing
34
34
  # The same write-target extractor the edit ledger uses after the fact. Its
35
35
  # absence degrades the shell branch to the read-only scan, never to a crash.
36
36
  try:
37
- from _shell_writes import shell_write_targets
37
+ from _shell_writes import msys_drive, quoted_paths, shell_write_targets
38
38
  except Exception: # pragma: no cover — package-style import (dispatcher, tests)
39
39
  try:
40
- from cli._shell_writes import shell_write_targets
40
+ from cli._shell_writes import msys_drive, quoted_paths, shell_write_targets
41
41
  except Exception:
42
42
  shell_write_targets = None
43
43
 
44
+ def msys_drive(path: str) -> str:
45
+ return path
46
+
47
+ def quoted_paths(cmd: str) -> list:
48
+ return []
49
+
44
50
  _WRITE_TOOLS = {"Edit", "Write", "MultiEdit", "NotebookEdit"}
45
51
  _READ_TOOLS = {"Read", "SearchText"}
46
52
  _SEARCH_TOOLS = {"Grep", "Glob", "FindFiles"}
@@ -112,7 +118,20 @@ _DOUBLE_COLON_RE = re.compile(r"::(?!\$)")
112
118
  # `<rev>:<path>` — how git names a blob: `git show HEAD:setup.py`,
113
119
  # `git cat-file -p origin/main:src/a.py`.
114
120
  _GIT_REVSPEC_RE = re.compile(r"^(?P<rev>[^:\s]+):(?P<path>[^:\s]+)$")
115
- _GIT_CMD_RE = re.compile(r"^\s*(?:[\w.\-]*[/\\])?git(?:\.exe)?\b", re.IGNORECASE)
121
+ # Loop and conditional bodies (`do git show …`) and env prefixes
122
+ # (`GIT_PAGER= git show …`) are still git commands.
123
+ _GIT_CMD_RE = re.compile(
124
+ r"^\s*(?:(?:do|then|else|time|exec|command)\s+|[!({]\s*|[A-Za-z_]\w*=\S*\s+)*"
125
+ r"(?:[\w.\-]*[/\\])?git(?:\.exe)?\b",
126
+ re.IGNORECASE,
127
+ )
128
+
129
+ # Refusals that judge how a path is SPELLED rather than which file it names.
130
+ # A shell token that trips one is usually not a path at all, so these are
131
+ # re-judged as the file they could reach (_spelling_verdict).
132
+ _SPELLING_RULES = frozenset({"<ads>", "<unc>", "<empty-component>", "<8.3-alias>"})
133
+ # `\\host\share` or `//host/share`: one separator between host and share.
134
+ _UNC_SHARE_RE = re.compile(r"^(?:\\\\|//)[^\\/\s]+[\\/][^\\/\s]+")
116
135
 
117
136
  # Where one command ends and the next begins. Anchoring "is this git?" to the
118
137
  # start of the whole string was wrong in the most ordinary way possible:
@@ -190,6 +209,56 @@ def _looks_like_a_path(tok: str) -> bool:
190
209
  return not (_SYNTAX_CHARS & set(tok))
191
210
 
192
211
 
212
+ def _exists(path: str) -> bool:
213
+ try:
214
+ return Path(path).exists()
215
+ except (OSError, ValueError):
216
+ return False
217
+
218
+
219
+ def _stream_base(path: str) -> str:
220
+ """`C:/x/f.txt:name:$DATA` -> `C:/x/f.txt`: the file a stream belongs to."""
221
+ head = path[:2] if re.match(r"^[A-Za-z]:", path) else ""
222
+ return head + path[len(head):].split(":", 1)[0]
223
+
224
+
225
+ def _dots_collapsed(path: str) -> str:
226
+ """The path Windows opens for a spelling with dot-only components.
227
+
228
+ Win32 strips trailing dots and spaces, so `a/.../b` and `a/x/../b` both
229
+ land somewhere real; model that before asking which file it is.
230
+ """
231
+ parts = re.split(r"[\\/]", path)
232
+ kept = [p if p in ("", ".", "..") or p.rstrip(". ") else "." for p in parts]
233
+ return os.path.normpath("/".join(kept))
234
+
235
+
236
+ def _spelling_verdict(denial, tok: str, probe: str, base: str):
237
+ """The deny a path-spelling refusal stands for in a shell command, or None.
238
+
239
+ The spelling rules keep a protected file from being reached under an odd
240
+ name. Tokens that trip them in shell text are mostly not paths
241
+ (`origin/main:x`, `// comment`, `taskkill //F`, `...`), so the token is
242
+ judged as the file it could name, with the usual existence gate, and
243
+ refused only when that file is denied. A real UNC share stays denied: a
244
+ network path cannot be judged locally.
245
+ """
246
+ if denial.rule == "<unc>":
247
+ unc = any(_UNC_SHARE_RE.match(t) for t in (tok, tok.replace("\\\\", "\\")))
248
+ return denial if unc else None
249
+ if denial.rule == "<ads>":
250
+ target = _stream_base(probe)
251
+ elif denial.rule == "<empty-component>":
252
+ target = _dots_collapsed(probe)
253
+ else:
254
+ return None # <8.3-alias>: a short name that does not exist names nothing
255
+ real = ag.check(target, "read", base)
256
+ if (real and real.kind == "deny" and not real.rule.startswith("<")
257
+ and _exists(target)):
258
+ return real
259
+ return None
260
+
261
+
193
262
  def _deny(reason: str) -> dict:
194
263
  return {
195
264
  "hookSpecificOutput": {
@@ -290,7 +359,8 @@ def _cd_target(segment: str, cwd: str) -> str | None:
290
359
  if not target or target.startswith("-"):
291
360
  return None
292
361
  try:
293
- return os.path.abspath(os.path.join(cwd, os.path.expanduser(target)))
362
+ return os.path.abspath(
363
+ os.path.join(cwd, msys_drive(os.path.expanduser(target))))
294
364
  except (OSError, ValueError):
295
365
  return None
296
366
 
@@ -300,12 +370,13 @@ def _scan_shell(cmd: str, base: str):
300
370
 
301
371
  Confident = the token resolves to an EXISTING path that a ``deny`` rule
302
372
  covers (existence-gating keeps regex/pattern arguments like '\\.env'
303
- from false-denying), or the evaluator flags the spelling itself.
373
+ from false-denying). A spelling refusal (``<ads>``, ``<unc>``, …) counts
374
+ only when the file the spelling could reach is itself denied
375
+ (``_spelling_verdict``). Quoted substrings are judged as well, so a
376
+ quoted path with spaces is not lost to whitespace splitting.
304
377
 
305
378
  Tokens that are shell syntax rather than path arguments are skipped
306
- outright, as are URLs and IPv6 literals: all of them trip the ADS spelling
307
- check, which is exempt from existence-gating, so a token naming nothing on
308
- disk would otherwise hard-deny (#50).
379
+ outright, as are URLs and IPv6 literals.
309
380
 
310
381
  Scanning is per **command segment**, not per whole string. A segment is what
311
382
  sits between `&&`, `||`, `;`, `|` or a newline, and each one answers "am I a
@@ -315,6 +386,7 @@ def _scan_shell(cmd: str, base: str):
315
386
  """
316
387
  budget = _MAX_TOKENS
317
388
  cwd = base
389
+ visited = [base]
318
390
  for segment in _SEGMENT_SPLIT.split(cmd or ""):
319
391
  if budget <= 0:
320
392
  break
@@ -347,8 +419,7 @@ def _scan_shell(cmd: str, base: str):
347
419
  from_revspec = revspec_path is not None
348
420
  if from_revspec:
349
421
  tok = revspec_path
350
- if re.match(r"^/[a-z]/", tok): # MSYS /c/foo → C:/foo
351
- tok = f"{tok[1]}:{tok[2:]}"
422
+ tok = msys_drive(tok)
352
423
  # Resolve against the cwd the command will actually run in, not the
353
424
  # session root. `cd /elsewhere && cat .env` used to compute the
354
425
  # denial correctly and then throw it away, because the existence
@@ -363,10 +434,12 @@ def _scan_shell(cmd: str, base: str):
363
434
  probe = tok
364
435
  denial = ag.check(probe, "read", base)
365
436
  if denial and denial.kind == "deny":
366
- try:
367
- exists = Path(probe).exists()
368
- except OSError:
369
- exists = False
437
+ if denial.rule in _SPELLING_RULES:
438
+ denial = _spelling_verdict(denial, tok, probe, base)
439
+ if denial is not None:
440
+ return denial, tok
441
+ continue
442
+ exists = _exists(probe)
370
443
  # A revspec names a path in HISTORY, so the working tree is the
371
444
  # wrong place to ask whether it is real. `git show HEAD~5:.env`
372
445
  # reads a denied file whether or not that file exists today, and
@@ -378,6 +451,34 @@ def _scan_shell(cmd: str, base: str):
378
451
  moved = _cd_target(segment, cwd)
379
452
  if moved is not None:
380
453
  cwd = moved
454
+ visited.append(cwd)
455
+ return _scan_quoted(cmd, visited, base)
456
+
457
+
458
+ def _scan_quoted(cmd: str, dirs: list, base: str):
459
+ """(denial, token) for a quoted path naming an existing denied file.
460
+
461
+ Quotes can span the segment separators, so this runs over the whole
462
+ command and resolves a relative path against every directory the scan
463
+ visited. A quoted `//host/path` is far more often a protocol-relative URL
464
+ in code than a share, so `<unc>` is not judged here; the token scan still
465
+ judges it.
466
+ """
467
+ for raw in quoted_paths(cmd):
468
+ if _is_network_token(raw):
469
+ continue
470
+ tok = msys_drive(os.path.expanduser(raw))
471
+ for here in ([base] if os.path.isabs(tok) else dirs):
472
+ probe = tok if os.path.isabs(tok) else os.path.join(here, tok)
473
+ denial = ag.check(probe, "read", base)
474
+ if not denial or denial.kind != "deny" or denial.rule == "<unc>":
475
+ continue
476
+ if denial.rule in _SPELLING_RULES:
477
+ denial = _spelling_verdict(denial, tok, probe, base)
478
+ elif not (_exists(probe) or denial.rule.startswith("<")):
479
+ denial = None
480
+ if denial is not None:
481
+ return denial, tok
381
482
  return None, ""
382
483
 
383
484
 
cli/tools/shell.py CHANGED
@@ -19,6 +19,7 @@ such as jq; use Python's stdlib JSON support when portability matters.
19
19
  from __future__ import annotations
20
20
 
21
21
  import asyncio
22
+ import glob
22
23
  import os
23
24
  import re
24
25
  import shutil
@@ -27,7 +28,7 @@ import sys
27
28
  import time
28
29
  from pathlib import Path
29
30
 
30
- from cli._shell_writes import shell_write_targets
31
+ from cli._shell_writes import msys_drive, quoted_paths, shell_write_targets
31
32
  from cli.tools import _grants
32
33
  from cli.tools._helpers import finalize_with_tokens
33
34
  from cli.tools.shell_nudge import bypass_hint
@@ -737,6 +738,15 @@ _MSYS_DRIVE = re.compile(r"^/([a-zA-Z])(/|$)") # /c/foo → c:/foo (any drive)
737
738
  _URL_SCHEME = re.compile(r"^[a-zA-Z][a-zA-Z0-9+.-]*://")
738
739
  _DRIVE_PREFIX = re.compile(r"^[a-zA-Z]:[/\\]")
739
740
  _MAX_SCAN_TOKENS = 64
741
+ _CD_SEGMENT = re.compile(
742
+ r"""(?:^|&&|\|\||[;\n])\s*cd\s+(?:/d\s+)?("[^"]+"|'[^']+'|[^\s;&|]+)""",
743
+ re.IGNORECASE)
744
+ _MAX_SCAN_DIRS = 16
745
+ _GLOB_CHARS = frozenset("*?[")
746
+ _MAX_GLOB_HITS = 50
747
+ # Refusals that stand even for a token naming no existing file: the evaluator
748
+ # could not judge the command at all.
749
+ _FAIL_CLOSED_RULES = ("<corrupt-config>", "<evaluator-error>")
740
750
 
741
751
 
742
752
  def _scan_candidates(command: str, work_cwd: str) -> list[str]:
@@ -779,28 +789,79 @@ def _scan_candidates(command: str, work_cwd: str) -> list[str]:
779
789
  return out
780
790
 
781
791
 
782
- def _advisory_guard_scan(command: str, work_cwd: str, project_path: str):
783
- """(denial, token) when a path-shaped token hits a deny rule, else (None, '').
792
+ def _scan_dirs(command: str, work_cwd: str) -> list[str]:
793
+ """``work_cwd`` plus every directory a ``cd`` in the command may move to.
794
+
795
+ A union rather than a replay: the scan only needs to know where a
796
+ relative token could land, and over-including a directory can only add
797
+ refusals.
798
+ """
799
+ dirs = [work_cwd]
800
+ for m in _CD_SEGMENT.finditer(command or ""):
801
+ target = msys_drive(os.path.expanduser(m.group(1).strip("\"'")))
802
+ for here in list(dirs):
803
+ if len(dirs) >= _MAX_SCAN_DIRS:
804
+ return dirs
805
+ try:
806
+ dirs.append(os.path.normpath(os.path.join(here, target)))
807
+ except (OSError, ValueError):
808
+ continue
809
+ return dirs
810
+
811
+
812
+ def _existing_targets(tok: str, dirs: list[str], command: str = "") -> list[str]:
813
+ """Files ``tok`` names from any of ``dirs``, globs expanded as bash would.
784
814
 
785
- ADVISORY: only deny-kind rule hits (and the corrupt-config deny-all)
786
- refuse; canonicalization artifacts on tokens that may not be paths at
787
- all (UNC-ish, 8.3, unresolvable) are skipped so non-path tokens cannot
788
- veto commands. Evaluator errors fail closed (synthetic denial), matching
789
- the hook layer's posture.
815
+ Bash expands a pattern only outside quotes, and reads ``**`` as ``*``
816
+ without globstar, so a pattern is expanded only when it also appears
817
+ unquoted in ``command``, and matched that way.
790
818
  """
791
- for tok in _scan_candidates(command, work_cwd):
792
- target = tok if os.path.isabs(tok) else os.path.join(work_cwd, tok)
819
+ expand = bool(_GLOB_CHARS & set(tok)) and bool(
820
+ re.search(r"(?:^|[^'\"])" + re.escape(tok), command))
821
+ tok = os.path.expanduser(tok)
822
+ found: list[str] = []
823
+ for here in ([""] if os.path.isabs(tok) else dirs):
824
+ path = os.path.join(here, tok) if here else tok
793
825
  try:
794
- denial = access_guard.check(target, "read", project_path)
795
- except Exception as exc: # fail closed — mirror hook _FAIL_CLOSED
796
- return access_guard.Denial(
797
- "<evaluator-error>", "deny", "builtin",
798
- f"evaluator error: {type(exc).__name__}"), tok
799
- if denial is None or denial.kind != "deny":
826
+ if expand:
827
+ found.extend(glob.glob(path.replace("**", "*"))[:_MAX_GLOB_HITS])
828
+ elif os.path.lexists(path):
829
+ found.append(path)
830
+ except (OSError, ValueError):
800
831
  continue
801
- if denial.rule.startswith("<") and denial.rule != "<corrupt-config>":
802
- continue # canonicalization artifact on a maybe-not-a-path token
803
- return denial, tok
832
+ return found
833
+
834
+
835
+ def _advisory_guard_scan(command: str, work_cwd: str, project_path: str):
836
+ """(denial, token) when a token names an existing denied file, else (None, '').
837
+
838
+ ADVISORY: a deny rule refuses only for a file that exists from the
839
+ command's cwd or a directory it ``cd``s to, with globs expanded. Text that
840
+ merely matches a glob (``\\.env`` in a regex, ``event.key`` in code) names
841
+ nothing to read. Canonicalization artifacts on tokens that may not be
842
+ paths at all (UNC-ish, 8.3, unresolvable) are skipped. A corrupt config
843
+ and evaluator errors refuse regardless, matching the hook layer.
844
+ """
845
+ dirs = _scan_dirs(command, work_cwd)
846
+ quoted = [msys_drive(q) for q in quoted_paths(command)
847
+ if not _URL_SCHEME.match(q)]
848
+ candidates = [(t, command) for t in _scan_candidates(command, work_cwd)]
849
+ for tok, context in candidates + [(q, "") for q in quoted]:
850
+ hits = _existing_targets(tok, dirs, context)
851
+ judged = hits or [tok if os.path.isabs(tok) else os.path.join(work_cwd, tok)]
852
+ for target in judged:
853
+ try:
854
+ denial = access_guard.check(target, "read", project_path)
855
+ except Exception as exc: # fail closed — mirror hook _FAIL_CLOSED
856
+ return access_guard.Denial(
857
+ "<evaluator-error>", "deny", "builtin",
858
+ f"evaluator error: {type(exc).__name__}"), tok
859
+ if denial is None or denial.kind != "deny":
860
+ continue
861
+ if denial.rule in _FAIL_CLOSED_RULES:
862
+ return denial, tok
863
+ if hits and not denial.rule.startswith("<"):
864
+ return denial, tok
804
865
  return None, ""
805
866
 
806
867
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-context-control
3
- Version: 2.157.1
3
+ Version: 2.157.2
4
4
  Summary: Local MCP code-intelligence for AI coding tools: surgical search/read/edit, agent-config version history, path-level access + masking guards, and a multi-project hub.
5
5
  Author-email: Dimitri Tselenchuk <dtselenc@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -1,10 +1,10 @@
1
1
  cli/__init__.py,sha256=ec66drCZGNMRU4V6ov0zVhYZph1us12Vn8OvG_LJyRY,22
2
2
  cli/_hook_utils.py,sha256=RhfS2WS5VMSi2w2Jxcts1wg5WC-UFp89JOQvcO5Jjb8,23002
3
- cli/_shell_writes.py,sha256=XzUNlUDljmg-wZxK03xHnRe36WeQxe4tpO9HKVFwP5o,5090
4
- cli/c3.py,sha256=WClY2rFP9VgrZArBdjUCZs5qt0MfyxYGfItMKUeFD7M,439372
3
+ cli/_shell_writes.py,sha256=iBbzK0v0d29rhrYgF3zKJIJbb1WSZhQjD_6w8-nOUec,7348
4
+ cli/c3.py,sha256=YIGr7Jd94niwDp5m2ke-ldJ_pt3ZpfzN_26fUQ0D1rw,439372
5
5
  cli/docs.html,sha256=pPxcP5ieY0DcfEDvegwIcRxbz1woLZoKLVSF-4JVy0Q,146784
6
6
  cli/edits.html,sha256=UjAhoCmBmQ89cklGvJqzC6eyNP2tc8H6T-e01DVkLvE,43418
7
- cli/hook_access_guard.py,sha256=tzK3pQBGehDDZi6fECcYk8nRhy0QkmUtTF2TuJG7nbY,27928
7
+ cli/hook_access_guard.py,sha256=4UF2YHp5_vISH7Gvolc_Bz3ppSye2lGpGx38egRLj1g,32116
8
8
  cli/hook_agent_model.py,sha256=NzetPAuzl7eiWgr6tGzWUY24qiT717FD-QqeFOudGrg,2784
9
9
  cli/hook_artifact.py,sha256=Se1CNBfoBFyvJQlRmYdNtdRXIkQp9zaF0O6ndRMo7ts,2198
10
10
  cli/hook_auto_snapshot.py,sha256=yGFqRANtw8qNqRNr-oCgpuyaUyTkSzIOFxXt5kauq4I,5271
@@ -106,7 +106,7 @@ cli/tools/read.py,sha256=9W-FhALienlmWeLQnsUA9tvbTgh9IGJzbSYyoT9Wd7I,21439
106
106
  cli/tools/schedule.py,sha256=lOLEAMy7ANuxIm9GsA3GNVaKG1KnXOtAMeCNCWrcJDg,11390
107
107
  cli/tools/search.py,sha256=BZh3E7YggjCWOC1lJz0YNcRsdDLWsJiEmONtgUW2rEo,32397
108
108
  cli/tools/session.py,sha256=IYNgcNz_saQDvilX6iB-SClLpfsGmz_grgMY5PFztPI,9371
109
- cli/tools/shell.py,sha256=Zcsocl8IXeL9DSQNewq_fXECSufTccUdwc-H3S2Alto,58818
109
+ cli/tools/shell.py,sha256=gmFtq0eV8DWqOjZS21xKf58JIEYx_l_7B75uGpiDVRI,61353
110
110
  cli/tools/shell_job.py,sha256=_ilFBL3ulmqx8mwQJFUG6xW5dN-4NHqe0EZfRJL2e-4,16451
111
111
  cli/tools/shell_nudge.py,sha256=8UAK-9yOau2gm-vEtEzZdaz_8hJ_rVD2Zy1iEqrzD9s,8165
112
112
  cli/tools/shell_parsers.py,sha256=qzk_3U-HLK_vjUSve9ltqfipFncqbutOYMM3CpL49R8,28102
@@ -134,7 +134,7 @@ cli/ui/components/sessions.js,sha256=FIKtil76B8tCkAmcFV7hlj6GQ_DCJK2jCzvEmdK7NBE
134
134
  cli/ui/components/settings.js,sha256=FXcn-UQE2mXC6HFsLeEas-wAUFKt0OJaLySroZQMhGA,84095
135
135
  cli/ui/components/sidebar.js,sha256=K2ym2kUgpbyG-EBA_wBIIiqQY8qTatsiBZwzseMWuIQ,9939
136
136
  cli/ui/components/tasks.js,sha256=vyKQ3uwoppMwvdEaHlhWXW4oWcAisx4NveqzMhsYqHo,38438
137
- code_context_control-2.157.1.dist-info/licenses/LICENSE,sha256=l8Kh5QCNWNvR6kIt8L0BUZvc2LAFiHv2c-FnsGnUZf4,11301
137
+ code_context_control-2.157.2.dist-info/licenses/LICENSE,sha256=l8Kh5QCNWNvR6kIt8L0BUZvc2LAFiHv2c-FnsGnUZf4,11301
138
138
  core/__init__.py,sha256=TSDCEcM4V7gcZVM3w2ykJaqEUch4Dkon-rivV17T73s,2501
139
139
  core/codex_patch.py,sha256=CxvT_rQIwPNTRJZj9EHJmx0ZdOeSLxjiixuLI3Z7lPc,2107
140
140
  core/config.py,sha256=wCjrZKXRywUbR6WRcO7optyOirAQ2DeRNdPCU0X5zIY,23762
@@ -194,7 +194,7 @@ oracle/ui/chat/send.js,sha256=X_Uc6EuuIxkUTlRWGGYOq6gQkJCQeCE3p5NMyxx7RzQ,11911
194
194
  oracle/ui/chat/stream_renderer.js,sha256=RZndI2mu5xbzZF-4NG9jeOqXTcmIqfZqxgkrBvTzWmk,29861
195
195
  oracle/ui/chat/toolbar.js,sha256=ZDexIIpGwsQ6XsY4Tyo082rJoofdD_JBTV97-mLQUVM,12027
196
196
  services/__init__.py,sha256=3Kn4cZweLm7at8wFdBdZ-Zwo8hHcnVIsmY5f29nzi2Y,116
197
- services/access_guard.py,sha256=Q-iJtxBdFL4n2clafUUB3-S3GVj6Y54X2rfjPSgCBMQ,81481
197
+ services/access_guard.py,sha256=ZKswPOCjHbu0jETV3vbJQgokOd3FsECUfVjKcRpfZFM,82052
198
198
  services/access_telemetry.py,sha256=9pOCLS9LgDtM7Z4cCEyl7osxhj-m3wsPubcXolBKuV4,9568
199
199
  services/activity_log.py,sha256=c_jTOsR-d1d5B3u67eg8mRA7LZhtP6H1-6leeGa0Go4,7990
200
200
  services/agent_base.py,sha256=a-gdSd_jtZtbjXo1WS8CnWCagXgKaGZd5ShcG6s0kT4,4809
@@ -349,8 +349,8 @@ tui/screens/search_view.py,sha256=MMHjVdlk3HZSuDBSvq8IGrqv_Mh5Us6YqXQ80bcWSMk,19
349
349
  tui/screens/session_view.py,sha256=eZ1eDwHTvPOck1wCCviixtOaCxIkBT_95ytNNNriGNA,5991
350
350
  tui/screens/stats.py,sha256=p81PjzdaIv7hllb8f45-rlVe4lJZwSdIMqu7e86_u5s,6223
351
351
  tui/screens/ui_view.py,sha256=1QJCgLh2YfgWIpvzRG1KOGXYEaOYX6ojN61Azjf2oX0,2125
352
- code_context_control-2.157.1.dist-info/METADATA,sha256=3HWe22L7OfBbflSgTyp6tXr5SuYkOqlHXP3rYVSgCTI,29355
353
- code_context_control-2.157.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
354
- code_context_control-2.157.1.dist-info/entry_points.txt,sha256=7kX_WUsDCF2hbXzvbNyscyaBb9AeA-DJY5v_5hN0DlU,93
355
- code_context_control-2.157.1.dist-info/top_level.txt,sha256=wRt41zBybVF3qAiNXHz9BURbkKvUvfhmWWtKMhaw6eE,29
356
- code_context_control-2.157.1.dist-info/RECORD,,
352
+ code_context_control-2.157.2.dist-info/METADATA,sha256=pdRks9dy5Jrybp6KWb4OGQQQ8WzxZeP5J118oERw6Ew,29355
353
+ code_context_control-2.157.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
354
+ code_context_control-2.157.2.dist-info/entry_points.txt,sha256=7kX_WUsDCF2hbXzvbNyscyaBb9AeA-DJY5v_5hN0DlU,93
355
+ code_context_control-2.157.2.dist-info/top_level.txt,sha256=wRt41zBybVF3qAiNXHz9BURbkKvUvfhmWWtKMhaw6eE,29
356
+ code_context_control-2.157.2.dist-info/RECORD,,
services/access_guard.py CHANGED
@@ -17,7 +17,7 @@ from __future__ import annotations
17
17
  import json
18
18
  import os
19
19
  import re
20
- from dataclasses import dataclass
20
+ from dataclasses import dataclass, replace
21
21
  from pathlib import Path
22
22
 
23
23
  from services.atomic_json import write_json_atomic
@@ -92,6 +92,10 @@ BUILTIN_ABSOLUTE_DENY = ("**/.c3/secrets.enc", "**/.c3/cred_state.json",
92
92
  # Tier 1 — a human may switch these off, but only through the two-key opt-out
93
93
  # below: a config entry AND a keyring attestation. Default is all enforced.
94
94
  BUILTIN_DENY = ("**/.env*", "**/.c3/edit_blobs/**")
95
+ # Committed templates that list variable names, not values. Outside
96
+ # `**/.env*` so an agent can read and update them.
97
+ _ENV_TEMPLATE_RE = re.compile(
98
+ r"^\.env(?:\.[^/.]+)*\.(?:example|sample|template|dist)$")
95
99
  # .grok/hooks/*.json is Grok Build's hook REGISTRATION (the command lines it
96
100
  # runs), the same role .claude/settings*.json plays for Claude Code, and Grok's
97
101
  # folder trust is granted per folder, not per hook file.
@@ -179,8 +183,12 @@ class Rule:
179
183
  # builtins, where confirm must cover reads or it silently becomes
180
184
  # allow-read. Ignored for every other kind.
181
185
  confirm_ops: str = "write"
186
+ # Leaf names the rule does not cover even when the glob matches them.
187
+ _except: re.Pattern | None = None
182
188
 
183
189
  def matches(self, canon: str, rel: str, name: str) -> bool:
190
+ if self._except is not None and self._except.match(name):
191
+ return False
184
192
  if self._basename:
185
193
  return bool(self._re.match(name))
186
194
  return bool(self._re.match(rel)) or bool(self._re.match(canon))
@@ -344,6 +352,10 @@ for _g in BUILTIN_CONFIRM_WRITE:
344
352
  confirm_ops="write"),
345
353
  }
346
354
  del _g
355
+ _BUILTIN_VARIANTS["**/.env*"] = {
356
+ mode: replace(rule, _except=_ENV_TEMPLATE_RE)
357
+ for mode, rule in _BUILTIN_VARIANTS["**/.env*"].items()
358
+ }
347
359
 
348
360
 
349
361
  def _builtin_rules_effective(modes: dict | None = None,