tokensafe 4.13.3 → 4.15.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.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/hooks/claude_code_hook.py +8 -2
- package/hooks/cursor_hook.py +2 -1
- package/hooks/kimi_hook.py +2 -1
- package/hooks/post_tool_use.py +15 -1
- package/hooks/pre_invocation.py +4 -2
- package/hooks/pre_tool_use.py +13 -6
- package/hooks/session_start.py +7 -2
- package/hooks/stop_hook.py +2 -1
- package/hooks/zcode_hook.py +2 -1
- package/kimi.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/server.json +3 -3
- package/src/acp/server.py +5 -0
- package/src/atomic_io.py +74 -0
- package/src/auto_inject.py +8 -4
- package/src/backend_release.py +3 -3
- package/src/batch_editor.py +2 -14
- package/src/cli.py +10 -0
- package/src/command_sanitizer.py +1 -1
- package/src/context_index.py +954 -0
- package/src/file_state.py +4 -3
- package/src/fts_index.py +12 -32
- package/src/graph_engine.py +43 -95
- package/src/guard.py +1 -1
- package/src/installer.py +64 -4
- package/src/license_manager.py +66 -0
- package/src/mcp_proxy.py +3 -0
- package/src/mcp_server.py +103 -5
- package/src/mistakes.py +45 -21
- package/src/oumv_gateway.py +61 -18
- package/src/paths.py +5 -12
- package/src/project_memory.py +264 -0
- package/src/result_ledger.py +40 -0
- package/src/retrofit.py +15 -8
- package/src/scoped_search.py +93 -53
- package/src/session_brief.py +14 -3
- package/src/skeletonizer.py +44 -2
- package/src/snapshot.py +17 -1
- package/src/stdio_io.py +50 -0
- package/src/telemetry_sync.py +1 -1
- package/src/version_checker.py +1 -1
- package/src/win_paths.py +172 -0
- package/src/workspace_roots.py +2 -6
package/README.md
CHANGED
|
@@ -266,7 +266,7 @@ Full matrix and details: [docs/OUMV.md](docs/OUMV.md).
|
|
|
266
266
|
Real 12-assertion oracle re-run after every step; tokens and cost from the provider's `usage`
|
|
267
267
|
payload. `baseline` = file/search/command tools, `tokensafe` = this product's MCP server
|
|
268
268
|
(`smart_read_file(endpoint="POST /api/…")` in one call → `apply_edits` with the hunk and inline
|
|
269
|
-
`verify="auto"`), `oumv` = the OUMV runtime
|
|
269
|
+
`verify="auto"`), `oumv` = the OUMV runtime measured in November 2026 (`observe L3` returns the handler, its
|
|
270
270
|
version and the same-package callees; `applyEdit mode=patch` carries an inline `verify` probe and
|
|
271
271
|
an actionable `-32009`). The Go sandbox is the benchmark module plus **200 generated service
|
|
272
272
|
files**; the React sandbox is a TaskManager store + component whose declared `npm test` is the
|
|
@@ -64,7 +64,12 @@ def handle(event: str, payload: dict, agent: str = AGENT) -> dict:
|
|
|
64
64
|
start_cwd = str(payload.get("cwd") or os.getcwd())
|
|
65
65
|
if is_project_root(start_cwd):
|
|
66
66
|
from src.graph_engine import GraphEngine
|
|
67
|
-
|
|
67
|
+
# A warm index answers without a rescan; only a repo that has
|
|
68
|
+
# never been indexed pays the one-time crawl (the banner is the product).
|
|
69
|
+
graph = GraphEngine.get_cached(start_cwd)
|
|
70
|
+
if graph is None:
|
|
71
|
+
graph = GraphEngine.get_instance(start_cwd)
|
|
72
|
+
banner = graph.format_topology_banner()
|
|
68
73
|
if banner:
|
|
69
74
|
extra = (
|
|
70
75
|
f"{extra}\n\n{banner}\n"
|
|
@@ -304,7 +309,8 @@ def handle(event: str, payload: dict, agent: str = AGENT) -> dict:
|
|
|
304
309
|
|
|
305
310
|
def main():
|
|
306
311
|
try:
|
|
307
|
-
|
|
312
|
+
from src.stdio_io import read_stdin_text
|
|
313
|
+
raw = read_stdin_text()
|
|
308
314
|
payload = json.loads(raw) if raw.strip() else {}
|
|
309
315
|
if not isinstance(payload, dict):
|
|
310
316
|
payload = {}
|
package/hooks/cursor_hook.py
CHANGED
|
@@ -126,7 +126,8 @@ def handle(event: str, payload: dict) -> dict:
|
|
|
126
126
|
|
|
127
127
|
def main():
|
|
128
128
|
try:
|
|
129
|
-
|
|
129
|
+
from src.stdio_io import read_stdin_text
|
|
130
|
+
raw = read_stdin_text()
|
|
130
131
|
payload = json.loads(raw) if raw.strip() else {}
|
|
131
132
|
if not isinstance(payload, dict):
|
|
132
133
|
payload = {}
|
package/hooks/kimi_hook.py
CHANGED
|
@@ -214,7 +214,8 @@ def handle(event: str, payload: dict) -> dict:
|
|
|
214
214
|
|
|
215
215
|
def main():
|
|
216
216
|
try:
|
|
217
|
-
|
|
217
|
+
from src.stdio_io import read_stdin_text
|
|
218
|
+
raw = read_stdin_text()
|
|
218
219
|
payload = json.loads(raw) if raw.strip() else {}
|
|
219
220
|
if not isinstance(payload, dict):
|
|
220
221
|
payload = {}
|
package/hooks/post_tool_use.py
CHANGED
|
@@ -35,7 +35,8 @@ def _should_skip_fast() -> bool:
|
|
|
35
35
|
def main():
|
|
36
36
|
raw = ""
|
|
37
37
|
try:
|
|
38
|
-
|
|
38
|
+
from src.stdio_io import read_stdin_text
|
|
39
|
+
raw = read_stdin_text()
|
|
39
40
|
except Exception:
|
|
40
41
|
raw = ""
|
|
41
42
|
|
|
@@ -101,6 +102,19 @@ def main():
|
|
|
101
102
|
)
|
|
102
103
|
except Exception:
|
|
103
104
|
pass
|
|
105
|
+
|
|
106
|
+
# Known-good commands: remember what actually passed here.
|
|
107
|
+
if cmd:
|
|
108
|
+
try:
|
|
109
|
+
from src.project_memory import ProjectMemory
|
|
110
|
+
hook_cwd = str(payload.get("cwd") or os.getcwd())
|
|
111
|
+
ProjectMemory(hook_cwd).record_command(
|
|
112
|
+
cmd,
|
|
113
|
+
cwd=hook_cwd,
|
|
114
|
+
exit_code=int(exit_code) if exit_code is not None else (1 if is_failed else 0),
|
|
115
|
+
)
|
|
116
|
+
except Exception:
|
|
117
|
+
pass
|
|
104
118
|
except Exception:
|
|
105
119
|
pass
|
|
106
120
|
|
package/hooks/pre_invocation.py
CHANGED
|
@@ -21,7 +21,6 @@ PROJECT_ROOT = os.path.dirname(HOOK_DIR)
|
|
|
21
21
|
if PROJECT_ROOT not in sys.path:
|
|
22
22
|
sys.path.insert(0, PROJECT_ROOT)
|
|
23
23
|
|
|
24
|
-
from src.agent import context as kernel
|
|
25
24
|
from src.adapter_core import TOKENSAFE_DIRECTIVES as PROTOCOL_DIRECTIVES, resolve_event_model
|
|
26
25
|
from src.license_manager import LicenseManager
|
|
27
26
|
from src.metrics import MetricsTracker
|
|
@@ -100,6 +99,7 @@ def _handle(payload: dict) -> dict:
|
|
|
100
99
|
}
|
|
101
100
|
})
|
|
102
101
|
elif last_user_input and len(last_user_input.strip()) >= 5 and not _proxy_is_active():
|
|
102
|
+
from src.agent import context as kernel
|
|
103
103
|
compaction = kernel.compact_prompt(last_user_input)
|
|
104
104
|
saved_tokens = compaction["saved_tokens"]
|
|
105
105
|
reduction_pct = compaction["reduction_pct"]
|
|
@@ -158,6 +158,7 @@ def _handle(payload: dict) -> dict:
|
|
|
158
158
|
fresh_fold = False
|
|
159
159
|
orig_hist_tokens = 0
|
|
160
160
|
if not is_quota_exceeded and invocation_num >= 3 and transcript_path:
|
|
161
|
+
from src.agent import context as kernel
|
|
161
162
|
folded_text, orig_hist_tokens, folded_tokens, stats = kernel.fold_history(
|
|
162
163
|
transcript_path, invocation_num
|
|
163
164
|
)
|
|
@@ -335,7 +336,8 @@ def _handle(payload: dict) -> dict:
|
|
|
335
336
|
|
|
336
337
|
def main():
|
|
337
338
|
try:
|
|
338
|
-
|
|
339
|
+
from src.stdio_io import read_stdin_text
|
|
340
|
+
raw_input = read_stdin_text()
|
|
339
341
|
if not raw_input.strip():
|
|
340
342
|
print(json.dumps({}))
|
|
341
343
|
return
|
package/hooks/pre_tool_use.py
CHANGED
|
@@ -76,13 +76,10 @@ def _handle(payload: dict) -> dict:
|
|
|
76
76
|
except Exception:
|
|
77
77
|
pass
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
quota = LicenseManager.check_quota(tracker)
|
|
81
|
-
is_quota_exceeded = bool(quota.get("is_quota_exceeded", False))
|
|
82
|
-
|
|
83
|
-
# 1. Loop Detector Guard (Applies to all tools)
|
|
79
|
+
# 1. Loop Detector Guard (Applies to all tools; one JSON file, cheap)
|
|
84
80
|
is_loop, repeat_count, loop_msg = LoopDetector.check_loop(conversation_id, tool_name, args)
|
|
85
81
|
if is_loop:
|
|
82
|
+
tracker = MetricsTracker()
|
|
86
83
|
try:
|
|
87
84
|
from src.mistakes import MistakesLedger
|
|
88
85
|
MistakesLedger.record_from_loop(tool_name, args, repeat_count, project_root=hook_cwd)
|
|
@@ -100,6 +97,15 @@ def _handle(payload: dict) -> dict:
|
|
|
100
97
|
|
|
101
98
|
response: dict = {"decision": "allow"}
|
|
102
99
|
|
|
100
|
+
# Search/list/other tools only ever answer "allow"; quota checks and event
|
|
101
|
+
# recording are skipped for them. The guarded set is read/write/edit/bash.
|
|
102
|
+
if canon_tool not in ("read", "write", "edit", "bash"):
|
|
103
|
+
return response
|
|
104
|
+
|
|
105
|
+
tracker = MetricsTracker()
|
|
106
|
+
quota = LicenseManager.check_quota(tracker)
|
|
107
|
+
is_quota_exceeded = bool(quota.get("is_quota_exceeded", False))
|
|
108
|
+
|
|
103
109
|
# 1.5 Stale-file edit guard: when the target changed on disk since the
|
|
104
110
|
# model last saw it (build output, linters, another session), the edit
|
|
105
111
|
# either corrupts content or fails and forces a costly full re-read.
|
|
@@ -431,7 +437,8 @@ def _handle(payload: dict) -> dict:
|
|
|
431
437
|
|
|
432
438
|
def main():
|
|
433
439
|
try:
|
|
434
|
-
|
|
440
|
+
from src.stdio_io import read_stdin_text
|
|
441
|
+
raw_input = read_stdin_text()
|
|
435
442
|
if not raw_input.strip():
|
|
436
443
|
print(json.dumps({"decision": "allow"}))
|
|
437
444
|
return
|
package/hooks/session_start.py
CHANGED
|
@@ -71,7 +71,8 @@ def _guest_pitch_step(quota: dict):
|
|
|
71
71
|
|
|
72
72
|
def main():
|
|
73
73
|
try:
|
|
74
|
-
|
|
74
|
+
from src.stdio_io import read_stdin_text
|
|
75
|
+
raw_input = read_stdin_text()
|
|
75
76
|
if not raw_input.strip():
|
|
76
77
|
print(json.dumps({}))
|
|
77
78
|
return
|
|
@@ -105,7 +106,11 @@ def main():
|
|
|
105
106
|
try:
|
|
106
107
|
if workspace_paths:
|
|
107
108
|
from src.graph_engine import GraphEngine
|
|
108
|
-
|
|
109
|
+
# A warm index answers without a rescan; only a repo that has never
|
|
110
|
+
# been indexed pays the one-time crawl (the banner is the product).
|
|
111
|
+
graph = GraphEngine.get_cached(workspace_root)
|
|
112
|
+
if graph is None:
|
|
113
|
+
graph = GraphEngine.get_instance(workspace_root)
|
|
109
114
|
banner = graph.format_topology_banner()
|
|
110
115
|
extra = []
|
|
111
116
|
if banner:
|
package/hooks/stop_hook.py
CHANGED
package/hooks/zcode_hook.py
CHANGED
|
@@ -58,7 +58,8 @@ def handle(event: str, payload: dict) -> dict:
|
|
|
58
58
|
|
|
59
59
|
def main():
|
|
60
60
|
try:
|
|
61
|
-
|
|
61
|
+
from src.stdio_io import read_stdin_text
|
|
62
|
+
raw = read_stdin_text()
|
|
62
63
|
payload = json.loads(raw) if raw.strip() else {}
|
|
63
64
|
if not isinstance(payload, dict):
|
|
64
65
|
payload = {}
|
package/kimi.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.0",
|
|
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": "Apache-2.0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.15.0",
|
|
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.
|
|
4
|
+
"version": "4.15.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"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.",
|
|
7
7
|
"logo": "assets/logo.png",
|
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
|
+
"version": "4.15.0",
|
|
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.
|
|
26
|
+
"version": "4.15.0",
|
|
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.
|
|
42
|
+
"version": "4.15.0",
|
|
43
43
|
"runtimeHint": "uvx",
|
|
44
44
|
"transport": {
|
|
45
45
|
"type": "stdio"
|
package/src/acp/server.py
CHANGED
|
@@ -440,6 +440,11 @@ def _version() -> str:
|
|
|
440
440
|
|
|
441
441
|
|
|
442
442
|
def run_acp_server(provider_factory: Optional[Callable[[str, str], Provider]] = None) -> None:
|
|
443
|
+
# Windows pipes default to the ANSI code page; agent responses routinely
|
|
444
|
+
# carry non-Latin-1 text.
|
|
445
|
+
from src.stdio_io import ensure_utf8_stdio
|
|
446
|
+
|
|
447
|
+
ensure_utf8_stdio()
|
|
443
448
|
# Editors expect the prompt; headless harnesses set off|all explicitly.
|
|
444
449
|
policy = os.environ.get("TOKENSAFE_ACP_PERMISSIONS", "writes")
|
|
445
450
|
server = AcpServer(sys.stdin, sys.stdout, provider_factory=provider_factory, permission_policy=policy)
|
package/src/atomic_io.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Crash-safe file writes.
|
|
2
|
+
|
|
3
|
+
A process killed between ``open()`` and the final rename would leave a
|
|
4
|
+
truncated file, and a power loss after ``os.replace`` can lose the rename
|
|
5
|
+
unless the directory entry is fsynced. OUMV mutations and ``apply_edits`` are
|
|
6
|
+
the two places where a half-written source file is unacceptable, so both go
|
|
7
|
+
through this helper: same-directory temp file -> flush + fsync -> chmod ->
|
|
8
|
+
``os.replace`` -> directory fsync on POSIX. Windows has no directory fsync;
|
|
9
|
+
``os.replace`` there is still atomic against a process crash.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import stat
|
|
16
|
+
import tempfile
|
|
17
|
+
from typing import Optional, Union
|
|
18
|
+
|
|
19
|
+
__all__ = ["write_atomic", "write_text_atomic"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _fsync_directory(directory: str) -> None:
|
|
23
|
+
if os.name != "posix" or not hasattr(os, "O_DIRECTORY"):
|
|
24
|
+
return
|
|
25
|
+
try:
|
|
26
|
+
fd = os.open(directory, os.O_DIRECTORY)
|
|
27
|
+
except OSError:
|
|
28
|
+
return
|
|
29
|
+
try:
|
|
30
|
+
os.fsync(fd)
|
|
31
|
+
finally:
|
|
32
|
+
os.close(fd)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def write_atomic(path: str, data: Union[bytes, str], *, mode: Optional[int] = None,
|
|
36
|
+
fsync: bool = True) -> str:
|
|
37
|
+
"""Writes ``data`` to ``path`` atomically and durably.
|
|
38
|
+
|
|
39
|
+
``mode`` defaults to the target's current permission bits (a new file keeps
|
|
40
|
+
the ``mkstemp`` 0600). Returns the path.
|
|
41
|
+
"""
|
|
42
|
+
abs_path = os.path.abspath(path)
|
|
43
|
+
directory = os.path.dirname(abs_path) or "."
|
|
44
|
+
os.makedirs(directory, exist_ok=True)
|
|
45
|
+
if mode is None and os.path.exists(abs_path):
|
|
46
|
+
try:
|
|
47
|
+
mode = stat.S_IMODE(os.stat(abs_path).st_mode)
|
|
48
|
+
except OSError:
|
|
49
|
+
mode = None
|
|
50
|
+
|
|
51
|
+
payload = data.encode("utf-8") if isinstance(data, str) else data
|
|
52
|
+
fd, tmp_path = tempfile.mkstemp(prefix=".tokensafe_atomic_", dir=directory)
|
|
53
|
+
try:
|
|
54
|
+
with os.fdopen(fd, "wb") as handle:
|
|
55
|
+
handle.write(payload)
|
|
56
|
+
handle.flush()
|
|
57
|
+
if fsync:
|
|
58
|
+
os.fsync(handle.fileno())
|
|
59
|
+
os.chmod(tmp_path, mode if mode is not None else 0o600)
|
|
60
|
+
os.replace(tmp_path, abs_path)
|
|
61
|
+
except BaseException:
|
|
62
|
+
try:
|
|
63
|
+
os.unlink(tmp_path)
|
|
64
|
+
except OSError:
|
|
65
|
+
pass
|
|
66
|
+
raise
|
|
67
|
+
if fsync:
|
|
68
|
+
_fsync_directory(directory)
|
|
69
|
+
return abs_path
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def write_text_atomic(path: str, text: str, *, mode: Optional[int] = None,
|
|
73
|
+
fsync: bool = True) -> str:
|
|
74
|
+
return write_atomic(path, text, mode=mode, fsync=fsync)
|
package/src/auto_inject.py
CHANGED
|
@@ -893,6 +893,8 @@ def _node_package_dir(workspace: str, entrypoint: str) -> str:
|
|
|
893
893
|
|
|
894
894
|
def _node_install_command(package_dir: str) -> Tuple[List[str], str]:
|
|
895
895
|
"""(argv, manager) for an exact install of the Node adapter package."""
|
|
896
|
+
from src.win_paths import resolve_executable
|
|
897
|
+
|
|
896
898
|
package = f"{_NODE_PACKAGE}@{BACKEND_NPM_VERSION}"
|
|
897
899
|
markers = (
|
|
898
900
|
("bun.lock", ["bun", "add"], "bun"),
|
|
@@ -903,8 +905,10 @@ def _node_install_command(package_dir: str) -> Tuple[List[str], str]:
|
|
|
903
905
|
)
|
|
904
906
|
for marker, prefix, manager in markers:
|
|
905
907
|
if os.path.isfile(os.path.join(package_dir, marker)):
|
|
906
|
-
|
|
907
|
-
|
|
908
|
+
binary = resolve_executable(prefix[0]) or prefix[0]
|
|
909
|
+
return [binary, *prefix[1:], package], manager
|
|
910
|
+
binary = resolve_executable("npm") or "npm"
|
|
911
|
+
return [binary, "install", "--save-exact", package], "npm"
|
|
908
912
|
|
|
909
913
|
|
|
910
914
|
def _node_package_installed(package_dir: str) -> bool:
|
|
@@ -1933,12 +1937,12 @@ _SIDECARS = {
|
|
|
1933
1937
|
"spring": (
|
|
1934
1938
|
"java/src/dev/tokensafe/oumv/OumvSpring.java",
|
|
1935
1939
|
"OumvSpring.java",
|
|
1936
|
-
"
|
|
1940
|
+
"edcb33b5c250ef6a087f20efe4fd9ebd8519f03e2f6f2f8484ff26835cf06694",
|
|
1937
1941
|
),
|
|
1938
1942
|
"php": (
|
|
1939
1943
|
"php/bin/oumv-php",
|
|
1940
1944
|
"oumv-php",
|
|
1941
|
-
"
|
|
1945
|
+
"ed61eabc1cd92b775a014a380f393922a3046a476ef9ed24d63a083623efefb2",
|
|
1942
1946
|
),
|
|
1943
1947
|
}
|
|
1944
1948
|
|
package/src/backend_release.py
CHANGED
|
@@ -10,7 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
# Backend tag (`vX.Y.Z`); the Go module resolves against the matching `go/vX.Y.Z`,
|
|
12
12
|
# which the backend release workflow creates alongside it.
|
|
13
|
-
BACKEND_RELEASE_TAG = "v0.
|
|
13
|
+
BACKEND_RELEASE_TAG = "v0.21.0"
|
|
14
14
|
|
|
15
15
|
# Wire version that tag speaks. Printed in briefs so an agent never mixes a
|
|
16
16
|
# backend release with an older protocol line.
|
|
@@ -19,9 +19,9 @@ BACKEND_WIRE_VERSION = "1.8.0"
|
|
|
19
19
|
# npm release of `tokensafe-backend-node` that ships the same adapters. The
|
|
20
20
|
# package has its own semver line (`node/package.json`), so it is pinned
|
|
21
21
|
# separately from the Go tag; `tokensafe inject` installs exactly this version.
|
|
22
|
-
BACKEND_NPM_VERSION = "0.
|
|
22
|
+
BACKEND_NPM_VERSION = "0.16.0"
|
|
23
23
|
|
|
24
24
|
# NuGet release of `TokenSafe.Oumv.AspNetCore`. It has its own semver line too
|
|
25
25
|
# (`dotnet/src/TokenSafe.Oumv/TokenSafe.Oumv.csproj`), so tying it to the Go tag
|
|
26
26
|
# would ask NuGet for a version that does not exist.
|
|
27
|
-
BACKEND_DOTNET_VERSION = "0.
|
|
27
|
+
BACKEND_DOTNET_VERSION = "0.8.0"
|
package/src/batch_editor.py
CHANGED
|
@@ -304,20 +304,8 @@ def _normalize_eol(text: str, newline: str) -> str:
|
|
|
304
304
|
def _write_atomic(abs_path: str, content: str, mode: Optional[int]) -> None:
|
|
305
305
|
"""Writes through a same-directory temp file + os.replace, so a failed write
|
|
306
306
|
never leaves a truncated target. Preserves `mode` when provided."""
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
try:
|
|
310
|
-
with os.fdopen(fd, "w", encoding="utf-8", newline="") as f:
|
|
311
|
-
f.write(content)
|
|
312
|
-
if mode is not None:
|
|
313
|
-
os.chmod(tmp_path, stat.S_IMODE(mode))
|
|
314
|
-
os.replace(tmp_path, abs_path)
|
|
315
|
-
except BaseException:
|
|
316
|
-
try:
|
|
317
|
-
os.unlink(tmp_path)
|
|
318
|
-
except OSError:
|
|
319
|
-
pass
|
|
320
|
-
raise
|
|
307
|
+
from src.atomic_io import write_text_atomic
|
|
308
|
+
write_text_atomic(abs_path, content, mode=stat.S_IMODE(mode) if mode is not None else None)
|
|
321
309
|
|
|
322
310
|
|
|
323
311
|
def _apply_hunk_to_text(
|
package/src/cli.py
CHANGED
|
@@ -889,6 +889,9 @@ def main(argv: Optional[List[str]] = None):
|
|
|
889
889
|
from src.retrofit import run_doctor
|
|
890
890
|
if "--prune" in args[2:]:
|
|
891
891
|
from src.oumv_gateway import OUMVGateway
|
|
892
|
+
from src.context_index import ContextIndex
|
|
893
|
+
from src.skeletonizer import Skeletonizer
|
|
894
|
+
from src.result_ledger import prune_archives
|
|
892
895
|
removed = OUMVGateway.prune_stale_descriptors(os.getcwd())
|
|
893
896
|
if removed:
|
|
894
897
|
print("removed stale OUMV descriptors:")
|
|
@@ -896,6 +899,13 @@ def main(argv: Optional[List[str]] = None):
|
|
|
896
899
|
print(f" - {path}")
|
|
897
900
|
else:
|
|
898
901
|
print("no stale OUMV descriptors to remove")
|
|
902
|
+
index_stats = ContextIndex.prune()
|
|
903
|
+
print(
|
|
904
|
+
f"pruned context indexes: {index_stats['removed']} "
|
|
905
|
+
f"({index_stats['freed_bytes'] // 1024} KB freed); "
|
|
906
|
+
f"skeletons: {Skeletonizer.prune()}; "
|
|
907
|
+
f"ledger archives: {prune_archives()}"
|
|
908
|
+
)
|
|
899
909
|
return
|
|
900
910
|
doc = run_doctor(os.getcwd())
|
|
901
911
|
print(f"\n\033[1m\033[36m⚡ TOKENSAFE OUMV DOCTOR ⚡\033[0m\n")
|
package/src/command_sanitizer.py
CHANGED