tokensafe 4.6.2 → 4.6.4
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.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +38 -5
- package/hooks/claude_code_hook.py +22 -0
- package/hooks/kimi_hook.py +20 -0
- package/hooks/pre_tool_use.py +0 -9
- package/hooks/session_start.py +16 -4
- package/kimi.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/adapter_core.py +57 -21
- package/src/auto_inject.py +517 -0
- package/src/batch_editor.py +36 -2
- package/src/batch_search.py +31 -5
- package/src/cli.py +152 -10
- package/src/command_sanitizer.py +92 -6
- package/src/guard.py +75 -11
- package/src/installer.py +6 -0
- package/src/mcp_server.py +84 -25
- package/src/oumv_gateway.py +168 -19
- package/src/paths.py +58 -0
- package/src/retrofit.py +219 -45
- package/src/savings.py +81 -0
- package/src/scaffold.py +190 -8
- package/src/session_brief.py +154 -0
- package/src/snapshot.py +3 -2
- package/src/telemetry_sync.py +98 -26
- package/src/transcript_analyzer.py +13 -9
- package/src/version_checker.py +1 -1
- package/hooks/__pycache__/claude_code_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/cursor_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/kimi_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/pre_invocation.cpython-312.pyc +0 -0
- package/hooks/__pycache__/pre_tool_use.cpython-312.pyc +0 -0
- package/hooks/__pycache__/session_start.cpython-312.pyc +0 -0
- package/hooks/__pycache__/stop_hook.cpython-312.pyc +0 -0
- package/hooks/__pycache__/zcode_hook.cpython-312.pyc +0 -0
package/README.md
CHANGED
|
@@ -204,10 +204,42 @@ Why TokenSafe agents ship working code on the first pass without burning quotas
|
|
|
204
204
|
|
|
205
205
|
Deeper mechanics (language matrix, AST syntax trees, cache tiers, governor) live in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
|
|
206
206
|
|
|
207
|
+
## What happens on the first prompt
|
|
208
|
+
|
|
209
|
+
You install TokenSafe, open a project in your agent, and the first turn does the wiring:
|
|
210
|
+
|
|
211
|
+
1. **Detect** the stack (React/Vue + Vite, FastAPI, Go/Gin|Chi, or nothing supported).
|
|
212
|
+
2. **Activate** the adapters:
|
|
213
|
+
* frontend — `tokensafe dev` serves OUMV from an inline Vite config; **no file in the
|
|
214
|
+
repository changes**;
|
|
215
|
+
* FastAPI — a global `~/.tokensafe/pyhooks/sitecustomize.py` mounts `mount_tokensafe(app)`
|
|
216
|
+
when the server runs through `tokensafe run-backend uvicorn ...`;
|
|
217
|
+
* Go — one `AutoMount()` line between `tokensafe:oumv` markers, byte-exact backup in
|
|
218
|
+
`~/.tokensafe/inject/`, `go build` validated, `tokensafe inject --revert` restores it.
|
|
219
|
+
3. **Brief the agent** — a short routing block (hook context and MCP `instructions`) says which
|
|
220
|
+
stack is worked through OUMV and which through the TokenSafe tools. Nothing is written into
|
|
221
|
+
the repository by the brief.
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
tokensafe inject --status # what would be wired, and where
|
|
225
|
+
tokensafe inject --dry-run # same, but explicit
|
|
226
|
+
tokensafe inject # apply the safe parts (config + Python autoload + Go line)
|
|
227
|
+
tokensafe inject --revert # restore the Go entrypoint byte-for-byte
|
|
228
|
+
tokensafe create shop --template react-fastapi # greenfield with everything pre-wired
|
|
229
|
+
tokensafe oumv doctor # readiness: adapter installed? runtime live? blocking reasons
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Full matrix and details: [docs/OUMV.md](docs/OUMV.md).
|
|
233
|
+
|
|
207
234
|
## Benchmarks
|
|
208
235
|
|
|
209
236
|
### Agent Usability Benchmarks (AUB) — Full-Stack Agent Velocity
|
|
210
237
|
|
|
238
|
+
> ⚠️ **Simulated, not measured.** These AER figures are computed from fixture traces in the
|
|
239
|
+
> benchmark harnesses (the 12-assertion oracles are real; the agent turns/tokens are not).
|
|
240
|
+
> A measured three-arm run (no TokenSafe / TokenSafe / OUMV) is the next benchmark milestone
|
|
241
|
+
> — until it lands, treat this table as a model, not as a product claim.
|
|
242
|
+
|
|
211
243
|
Beyond file slicing, TokenSafe's agent-native ecosystem eliminates architectural friction, state pollution, and compiler loops for autonomous coding agents across frontend and backend:
|
|
212
244
|
|
|
213
245
|
| Ecosystem Stack | Target Package | Baseline vs. TokenSafe | Autonomous Efficiency Ratio (AER) | Token Savings | Turns to Green | State Safety |
|
|
@@ -438,7 +470,7 @@ All hook adapters fail open: an internal error never stalls your agent. Failures
|
|
|
438
470
|
| `oumv_status` | Status, capabilities, and connection health of frontend/backend OUMV runtimes with hybrid fallback mode |
|
|
439
471
|
| `oumv_observe` | Progressive runtime observation (L0 pulse, L1 surface, L2 detail) with out-of-the-box static AST fallback |
|
|
440
472
|
| `oumv_understand` | Query runtime causality, state dependencies, and backend route mappings |
|
|
441
|
-
| `oumv_mutate` |
|
|
473
|
+
| `oumv_mutate` | OCC-guarded source edits (mandatory `expectedVersion`, path jail, syntax pre-flight, backup) |
|
|
442
474
|
| `oumv_verify` | Transactional verification and state invariant assertions |
|
|
443
475
|
</details>
|
|
444
476
|
|
|
@@ -541,12 +573,13 @@ TokenSafe integrates with the [OUMV Protocol](https://github.com/tokensafe-dev/o
|
|
|
541
573
|
- **Out-of-the-Box Stack Detection**: TokenSafe automatically detects your application stack (`package.json`, `go.mod`, `pyproject.toml`, Vite, Next.js, FastAPI, Gin) and configures agent tooling dynamically.
|
|
542
574
|
- **Level 1 Static AST Fallback**: When live dev-servers are offline, `oumv_observe` and `oumv_understand` gracefully fall back to zero-config static AST component trees and route maps with evidence tracking.
|
|
543
575
|
- **Consolidated Adapters**:
|
|
544
|
-
- **Frontend**:
|
|
576
|
+
- **Frontend**: `tokensafe-ui/react`, `tokensafe-ui/vue`, and the zero-footprint Vite bridge (`tokensafe-ui/vite`) with a session token stored in the per-workspace descriptor (`~/.tokensafe/runtimes/<hash>.json`, mode 0600).
|
|
545
577
|
- **Backend**: Go (`gin`, `chi`, `stdhttp`) and Python (`fastapi`, `sqlalchemy`) in [`tokensafe-backend`](https://github.com/tokensafe-dev/tokensafe-backend).
|
|
546
|
-
- **
|
|
547
|
-
- **
|
|
578
|
+
- **Guarded Mutations, Enabled by Default**: `oumv_mutate` works out of the box and guards every write — mandatory OCC `expectedVersion`, workspace path jail, syntax pre-flight, backup of previous bytes. Opt out with `permissions.mutate: false` in `.tokensafe/oumv.json`.
|
|
579
|
+
- **Automatic Wiring CLI**: `tokensafe inject` activates adapters with zero repository footprint (Vite wrapper, Python autoload, one marker-delimited Go line), `tokensafe inject --revert` restores it, and `tokensafe oumv doctor` reports readiness with blocking reasons.
|
|
580
|
+
- **Greenfield Recipes**: `tokensafe create <name> --template react-fastapi|react-go|vue-gin|fastapi|gin` generates a normal project in your stack with OUMV already wired.
|
|
548
581
|
|
|
549
|
-
More documentation: [docs/
|
|
582
|
+
More documentation: [docs/OUMV.md](docs/OUMV.md) · [docs/AGENT_SETUP.md](docs/AGENT_SETUP.md) · [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) · [docs/API.md](docs/API.md) · [METRICS.md](METRICS.md)
|
|
550
583
|
|
|
551
584
|
## Development and License
|
|
552
585
|
|
|
@@ -73,6 +73,17 @@ def handle(event: str, payload: dict, agent: str = AGENT) -> dict:
|
|
|
73
73
|
)
|
|
74
74
|
except Exception:
|
|
75
75
|
pass
|
|
76
|
+
# Routing brief: which stack is worked through OUMV vs TokenSafe tools.
|
|
77
|
+
try:
|
|
78
|
+
from src.paths import is_project_root as _is_project_root
|
|
79
|
+
from src.session_brief import build_workspace_brief
|
|
80
|
+
cwd_for_brief = str(payload.get("cwd") or os.getcwd())
|
|
81
|
+
if _is_project_root(cwd_for_brief):
|
|
82
|
+
routing = build_workspace_brief(cwd_for_brief, include_live=True)
|
|
83
|
+
if routing:
|
|
84
|
+
extra = f"{extra}\n\n{routing}"
|
|
85
|
+
except Exception:
|
|
86
|
+
pass
|
|
76
87
|
try:
|
|
77
88
|
from src.burn_monitor import get_burn_warnings
|
|
78
89
|
burn_warn = get_burn_warnings(
|
|
@@ -136,6 +147,17 @@ def handle(event: str, payload: dict, agent: str = AGENT) -> dict:
|
|
|
136
147
|
)
|
|
137
148
|
|
|
138
149
|
transcript_path = str(payload.get("transcript_path") or "")
|
|
150
|
+
# Routing brief: which stack is worked through OUMV vs TokenSafe tools.
|
|
151
|
+
try:
|
|
152
|
+
from src.paths import is_project_root as _is_project_root
|
|
153
|
+
from src.session_brief import build_workspace_brief
|
|
154
|
+
cwd_for_brief = str(payload.get("cwd") or os.getcwd())
|
|
155
|
+
if _is_project_root(cwd_for_brief):
|
|
156
|
+
routing = build_workspace_brief(cwd_for_brief, include_live=True)
|
|
157
|
+
if routing:
|
|
158
|
+
extra = f"{extra}\n\n{routing}"
|
|
159
|
+
except Exception:
|
|
160
|
+
pass
|
|
139
161
|
try:
|
|
140
162
|
from src.burn_monitor import get_burn_warnings
|
|
141
163
|
burn_warn = get_burn_warnings(
|
package/hooks/kimi_hook.py
CHANGED
|
@@ -55,6 +55,16 @@ def handle(event: str, payload: dict) -> dict:
|
|
|
55
55
|
extra = f"{extra}\n\n{guard}"
|
|
56
56
|
except Exception:
|
|
57
57
|
pass
|
|
58
|
+
try:
|
|
59
|
+
from src.paths import is_project_root as _is_project_root
|
|
60
|
+
from src.session_brief import build_workspace_brief
|
|
61
|
+
kimi_cwd = str(payload.get("cwd") or os.getcwd())
|
|
62
|
+
if _is_project_root(kimi_cwd):
|
|
63
|
+
routing = build_workspace_brief(kimi_cwd, include_live=True)
|
|
64
|
+
if routing:
|
|
65
|
+
extra = f"{extra}\n\n{routing}"
|
|
66
|
+
except Exception:
|
|
67
|
+
pass
|
|
58
68
|
try:
|
|
59
69
|
from src.burn_monitor import get_burn_warnings
|
|
60
70
|
burn_warn = get_burn_warnings(
|
|
@@ -116,6 +126,16 @@ def handle(event: str, payload: dict) -> dict:
|
|
|
116
126
|
f"(TokenSafe: compacted ~{meta['saved_tokens']} prompt tokens, "
|
|
117
127
|
f"-{meta.get('reduction_pct', 0)}% — original intent preserved.)"
|
|
118
128
|
)
|
|
129
|
+
try:
|
|
130
|
+
from src.paths import is_project_root as _is_project_root
|
|
131
|
+
from src.session_brief import build_workspace_brief
|
|
132
|
+
kimi_cwd = str(payload.get("cwd") or os.getcwd())
|
|
133
|
+
if _is_project_root(kimi_cwd):
|
|
134
|
+
routing = build_workspace_brief(kimi_cwd, include_live=True)
|
|
135
|
+
if routing:
|
|
136
|
+
extra = f"{extra}\n\n{routing}"
|
|
137
|
+
except Exception:
|
|
138
|
+
pass
|
|
119
139
|
try:
|
|
120
140
|
from src.burn_monitor import get_burn_warnings
|
|
121
141
|
burn_warn = get_burn_warnings(
|
package/hooks/pre_tool_use.py
CHANGED
|
@@ -174,15 +174,6 @@ def _handle(payload: dict) -> dict:
|
|
|
174
174
|
except Exception:
|
|
175
175
|
pass
|
|
176
176
|
|
|
177
|
-
if canon_tool == "edit" and not response.get("reason"):
|
|
178
|
-
try:
|
|
179
|
-
from src.adapter_core import get_oumv_read_edit_advisory
|
|
180
|
-
oumv_note = get_oumv_read_edit_advisory(hook_cwd, path or raw_path, conversation_id)
|
|
181
|
-
if oumv_note:
|
|
182
|
-
response["reason"] = oumv_note
|
|
183
|
-
except Exception:
|
|
184
|
-
pass
|
|
185
|
-
|
|
186
177
|
# 3. Output Guard (shared guard_write, v3.0.0): deny wholesale overwrite of
|
|
187
178
|
# large existing files to enforce edit_file; ask on small-delta writes.
|
|
188
179
|
if canon_tool == "write":
|
package/hooks/session_start.py
CHANGED
|
@@ -105,10 +105,8 @@ def main():
|
|
|
105
105
|
try:
|
|
106
106
|
if workspace_paths:
|
|
107
107
|
from src.graph_engine import GraphEngine
|
|
108
|
-
from src.retrofit import format_oumv_workspace_brief
|
|
109
108
|
graph = GraphEngine.get_instance(workspace_root)
|
|
110
109
|
banner = graph.format_topology_banner()
|
|
111
|
-
oumv_brief = format_oumv_workspace_brief(workspace_root, include_live=True)
|
|
112
110
|
extra = []
|
|
113
111
|
if banner:
|
|
114
112
|
extra.append(
|
|
@@ -116,8 +114,22 @@ def main():
|
|
|
116
114
|
"⚡ Core God Nodes and dependency hubs mapped above. "
|
|
117
115
|
"Call 'tokensafe:repo_map(view=\"graph\", project_path=...)' for full dependency trees."
|
|
118
116
|
)
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
# Separate try: an OUMV brief failure must not drop the God-Nodes banner.
|
|
118
|
+
try:
|
|
119
|
+
from src.retrofit import format_oumv_workspace_brief
|
|
120
|
+
oumv_brief = format_oumv_workspace_brief(workspace_root, include_live=True)
|
|
121
|
+
if oumv_brief:
|
|
122
|
+
extra.append(oumv_brief)
|
|
123
|
+
except Exception:
|
|
124
|
+
pass
|
|
125
|
+
# Routing brief: what goes through OUMV, what goes through TokenSafe tools.
|
|
126
|
+
try:
|
|
127
|
+
from src.session_brief import build_workspace_brief
|
|
128
|
+
routing = build_workspace_brief(workspace_root, include_live=True)
|
|
129
|
+
if routing:
|
|
130
|
+
extra.append(routing)
|
|
131
|
+
except Exception:
|
|
132
|
+
pass
|
|
121
133
|
if extra:
|
|
122
134
|
directives = f"{directives}\n\n" + "\n".join(extra)
|
|
123
135
|
except Exception:
|
package/kimi.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.4",
|
|
4
4
|
"description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
|
|
5
5
|
"homepage": "https://tokensafe.dev",
|
|
6
6
|
"license": "MIT",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "4.6.
|
|
4
|
+
"version": "4.6.4",
|
|
5
5
|
"description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
|
|
6
6
|
"main": "bin/tokensafe.js",
|
|
7
7
|
"bin": {
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"displayName": "TokenSafe",
|
|
4
|
-
"version": "4.6.
|
|
4
|
+
"version": "4.6.4",
|
|
5
5
|
"description": "Your AI agent is smart enough to code all day. Now it actually can. Local runtime firewall & zero-loss context optimizer for AI coding agents.",
|
|
6
6
|
"logo": "assets/logo.png",
|
|
7
7
|
"developerName": "TokenSafe",
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "dev.tokensafe/tokensafe",
|
|
4
4
|
"title": "TokenSafe",
|
|
5
5
|
"description": "Your AI agent is smart enough to code all day. Local firewall & zero-loss runtime.",
|
|
6
|
-
"version": "4.6.
|
|
6
|
+
"version": "4.6.4",
|
|
7
7
|
"websiteUrl": "https://tokensafe.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/tokensafe-dev/tokensafe",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
25
25
|
"identifier": "tokensafe",
|
|
26
|
-
"version": "4.6.
|
|
26
|
+
"version": "4.6.4",
|
|
27
27
|
"runtimeHint": "npx",
|
|
28
28
|
"transport": {
|
|
29
29
|
"type": "stdio"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"registryType": "pypi",
|
|
40
40
|
"registryBaseUrl": "https://pypi.org",
|
|
41
41
|
"identifier": "tokensafe",
|
|
42
|
-
"version": "4.6.
|
|
42
|
+
"version": "4.6.4",
|
|
43
43
|
"runtimeHint": "uvx",
|
|
44
44
|
"transport": {
|
|
45
45
|
"type": "stdio"
|
package/src/adapter_core.py
CHANGED
|
@@ -457,6 +457,35 @@ def _extract_path(tool_input: Dict[str, Any]) -> str:
|
|
|
457
457
|
return ""
|
|
458
458
|
|
|
459
459
|
|
|
460
|
+
_NUDGE_GC_AGE_SEC = 7 * 86400
|
|
461
|
+
|
|
462
|
+
# Hosts whose PreToolUse schema documents additionalContext, so an edit-time nudge
|
|
463
|
+
# can be delivered without a permissionDecision. ZCode/Kimi keep read-only nudges.
|
|
464
|
+
_OUMV_EDIT_NUDGE_AGENTS = ("claude_code", "claude")
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def _oumv_edit_nudge_enabled() -> bool:
|
|
468
|
+
"""Default-on, opt-out in the FileState style: TOKENSAFE_OUMV_EDIT_NUDGE=0."""
|
|
469
|
+
return os.environ.get("TOKENSAFE_OUMV_EDIT_NUDGE", "").strip().lower() not in ("0", "false", "no", "off")
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def _gc_oumv_markers(data_dir: str) -> None:
|
|
473
|
+
"""Drops one-shot OUMV markers older than a week: one accrues per session forever."""
|
|
474
|
+
try:
|
|
475
|
+
now = time.time()
|
|
476
|
+
for name in os.listdir(data_dir):
|
|
477
|
+
if not name.startswith((".oumv_nudge_", ".oumv_used_")):
|
|
478
|
+
continue
|
|
479
|
+
marker_path = os.path.join(data_dir, name)
|
|
480
|
+
try:
|
|
481
|
+
if now - os.path.getmtime(marker_path) > _NUDGE_GC_AGE_SEC:
|
|
482
|
+
os.unlink(marker_path)
|
|
483
|
+
except OSError:
|
|
484
|
+
pass
|
|
485
|
+
except Exception:
|
|
486
|
+
pass
|
|
487
|
+
|
|
488
|
+
|
|
460
489
|
def get_oumv_read_edit_advisory(workspace_dir: str, file_path: str, session_id: str = "") -> Optional[str]:
|
|
461
490
|
"""One-shot per-session advisory when reading/editing files inside an OUMV-supported stack
|
|
462
491
|
(React+Vite, Vue, Solid, Go, FastAPI) without having called `tokensafe:oumv` recently.
|
|
@@ -475,17 +504,21 @@ def get_oumv_read_edit_advisory(workspace_dir: str, file_path: str, session_id:
|
|
|
475
504
|
ws = workspace_dir or get_active_workspace()
|
|
476
505
|
if not ws or not os.path.isdir(ws):
|
|
477
506
|
return None
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
return None
|
|
507
|
+
# Cheap marker first: resolving the owning stack walks every manifest in
|
|
508
|
+
# the monorepo, and this runs on every read/write hook.
|
|
481
509
|
if OUMVGateway.was_recently_used(ws):
|
|
482
510
|
return None
|
|
511
|
+
pkg = is_path_in_supported_oumv_scope(ws, file_path, use_cache=True)
|
|
512
|
+
if not pkg:
|
|
513
|
+
return None
|
|
483
514
|
|
|
484
515
|
sess_key = hashlib.sha256(f"{session_id or 'default'}:{os.path.realpath(ws)}".encode("utf-8")).hexdigest()[:16]
|
|
485
|
-
|
|
516
|
+
data_dir = resolve_data_dir()
|
|
517
|
+
marker = os.path.join(data_dir, f".oumv_nudge_{sess_key}")
|
|
486
518
|
if os.path.isfile(marker):
|
|
487
519
|
return None
|
|
488
|
-
os.makedirs(
|
|
520
|
+
os.makedirs(data_dir, exist_ok=True)
|
|
521
|
+
_gc_oumv_markers(data_dir)
|
|
489
522
|
with open(marker, "w", encoding="utf-8") as f:
|
|
490
523
|
f.write(str(time.time()))
|
|
491
524
|
|
|
@@ -550,15 +583,14 @@ def evaluate_cc_pre_tool_use(payload: Dict[str, Any], agent: str) -> Dict[str, A
|
|
|
550
583
|
tp = str(payload.get("transcript_path") or "")
|
|
551
584
|
canon = canonical_tool_name(tool)
|
|
552
585
|
|
|
553
|
-
def _cc_decision(decision: str, reason: str
|
|
554
|
-
|
|
555
|
-
"
|
|
556
|
-
|
|
557
|
-
|
|
586
|
+
def _cc_decision(decision: str, reason: str) -> Dict[str, Any]:
|
|
587
|
+
return {
|
|
588
|
+
"hookSpecificOutput": {
|
|
589
|
+
"hookEventName": "PreToolUse",
|
|
590
|
+
"permissionDecision": decision,
|
|
591
|
+
"permissionDecisionReason": reason,
|
|
592
|
+
}
|
|
558
593
|
}
|
|
559
|
-
if extra_ctx:
|
|
560
|
-
inner["additionalContext"] = extra_ctx
|
|
561
|
-
return {"hookSpecificOutput": inner}
|
|
562
594
|
|
|
563
595
|
# 1. Loop Detector Guard (all tools)
|
|
564
596
|
try:
|
|
@@ -657,15 +689,19 @@ def evaluate_cc_pre_tool_use(payload: Dict[str, Any], agent: str) -> Dict[str, A
|
|
|
657
689
|
)
|
|
658
690
|
except Exception:
|
|
659
691
|
pass
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
692
|
+
# Advisory only, and only for hosts whose PreToolUse schema documents
|
|
693
|
+
# additionalContext (Claude Code): omitting permissionDecision keeps the
|
|
694
|
+
# normal permission flow, while returning "allow" used to auto-approve edits.
|
|
695
|
+
# Kill switch: TOKENSAFE_OUMV_EDIT_NUDGE=0.
|
|
696
|
+
if agent in _OUMV_EDIT_NUDGE_AGENTS and _oumv_edit_nudge_enabled():
|
|
697
|
+
note = get_oumv_read_edit_advisory(cwd, file_path, session_id)
|
|
698
|
+
if note:
|
|
699
|
+
return {
|
|
700
|
+
"hookSpecificOutput": {
|
|
701
|
+
"hookEventName": "PreToolUse",
|
|
702
|
+
"additionalContext": note,
|
|
703
|
+
}
|
|
667
704
|
}
|
|
668
|
-
}
|
|
669
705
|
return {}
|
|
670
706
|
|
|
671
707
|
if canon == "read":
|