tokensafe 4.1.6 → 4.1.8
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 +36 -0
- package/README.md +1 -1
- package/assets/logo.png +0 -0
- package/assets/logo.svg +13 -0
- package/assets/social/linkedin_banner.png +0 -0
- package/assets/social/tokensafe_logo_square.png +0 -0
- package/hooks/kimi_hook.py +237 -0
- package/kimi.plugin.json +62 -0
- package/package.json +5 -1
- package/plugin.json +6 -5
- package/rules/AGENTS.md +1 -1
- package/server.json +4 -4
- package/skills/token-optimizer/SKILL.md +4 -3
- package/skills/token-optimizer/references/cli-reference.md +1 -1
- package/skills/token-optimizer/references/mcp-tools.md +1 -1
- package/src/adapter_core.py +1 -1
- package/src/command_sanitizer.py +88 -15
- package/src/installer.py +135 -3
- package/src/mcp_server.py +8 -7
- package/src/telemetry_sync.py +1 -1
- package/src/test_parsers.py +110 -2
- package/src/version_checker.py +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "4.1.8",
|
|
3
|
+
"name": "tokensafe",
|
|
4
|
+
"description": "Your coding agent isn't getting dumber. Your context is just full of trash. Local context firewall & zero-loss runtime for Cursor, Claude Code, and autonomous agents.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "TokenSafe",
|
|
7
|
+
"url": "https://tokensafe.dev"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://tokensafe.dev",
|
|
10
|
+
"repository": "https://github.com/tokensafe-dev/tokensafe",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"tokensafe",
|
|
14
|
+
"token-optimizer",
|
|
15
|
+
"mcp",
|
|
16
|
+
"compression",
|
|
17
|
+
"ast-slicer",
|
|
18
|
+
"context-window"
|
|
19
|
+
],
|
|
20
|
+
"skills": "./skills/",
|
|
21
|
+
"interface": {
|
|
22
|
+
"displayName": "TokenSafe",
|
|
23
|
+
"shortDescription": "Stop coding agent context rot, destructive rewrites & secret leaks",
|
|
24
|
+
"longDescription": "TokenSafe is a local context firewall that strips massive lockfiles, verbose build logs, and repetitive file reads before they reach model attention. Zero-loss AST slicing, prompt cache prefix locking, and pre-commit secret guard for AI coding agents.",
|
|
25
|
+
"developerName": "TokenSafe",
|
|
26
|
+
"category": "Engineering",
|
|
27
|
+
"capabilities": [
|
|
28
|
+
"Read",
|
|
29
|
+
"Write",
|
|
30
|
+
"Analyze"
|
|
31
|
+
],
|
|
32
|
+
"websiteURL": "https://tokensafe.dev",
|
|
33
|
+
"brandColor": "#10B981",
|
|
34
|
+
"logo": "https://tokensafe.dev/logo.png"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/README.md
CHANGED
|
@@ -406,7 +406,7 @@ All hook adapters fail open: an internal error never stalls your agent. Failures
|
|
|
406
406
|
| `get_mistakes` | Anti-stuck persistent ledger: retrieves past dead-ends, loop guard trips, and git reverts to prevent repeating failed paths |
|
|
407
407
|
| `list_dir` | Clean directory tree without permissions, timestamps, or lockfiles |
|
|
408
408
|
| `slice_diff` | Unified diff slicing omitting lockfiles and minimizing context lines |
|
|
409
|
-
| `sanitize_command` | Per-stage shell command rewrites
|
|
409
|
+
| `sanitize_command` | Per-stage shell command rewrites (`git push` --no-progress, `git commit` hook wrapping, bun/python/jest test folding, lockfile exclusions, bounded logs) |
|
|
410
410
|
| `guard_inspect` | Pre-flight security and hygiene audit for commands or code snippets |
|
|
411
411
|
| `context_budget` | Context window usage estimate with thresholds and recommendations |
|
|
412
412
|
| `compress_prompt` | Compiles a verbose developer prompt into a compact S-expression |
|
package/assets/logo.png
ADDED
|
Binary file
|
package/assets/logo.svg
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<!-- Clean Obsidian Slate Squircle -->
|
|
3
|
+
<rect x="8" y="8" width="240" height="240" rx="52" fill="#090C10"/>
|
|
4
|
+
<rect x="8" y="8" width="240" height="240" rx="52" stroke="#1E293B" stroke-width="4"/>
|
|
5
|
+
|
|
6
|
+
<!-- Geometric Protective Vault Shield -->
|
|
7
|
+
<path d="M128 42 L194 68 V128 C194 170 166 204 128 218 C90 204 62 170 62 128 V68 L128 42 Z"
|
|
8
|
+
fill="#11161E" stroke="#10B981" stroke-width="10" stroke-linejoin="round"/>
|
|
9
|
+
|
|
10
|
+
<!-- Crisp Compression Bolt (High Contrast, 16px-ready) -->
|
|
11
|
+
<path d="M137 74 L97 132 H125 L119 182 L159 124 H131 L137 74 Z"
|
|
12
|
+
fill="#F3F4F6"/>
|
|
13
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TokenSafe adapter for Kimi Code lifecycle hooks.
|
|
4
|
+
|
|
5
|
+
Registered via kimi.plugin.json or ~/.kimi-code/config.toml:
|
|
6
|
+
SessionStart -> injects TokenSafe protocol directives once per session.
|
|
7
|
+
UserPromptSubmit -> compacts prompt into TOCP intent expression.
|
|
8
|
+
PreToolUse (Bash/Write/Read) -> denies secret leaks, destructive commands,
|
|
9
|
+
and unindexed lockfile/bundle reads.
|
|
10
|
+
|
|
11
|
+
Contract: stdin = one JSON payload, stdout = one JSON response.
|
|
12
|
+
Fail-open: any internal error emits `{}`.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
HOOK_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
20
|
+
PROJECT_ROOT = os.path.dirname(HOOK_DIR)
|
|
21
|
+
if PROJECT_ROOT not in sys.path:
|
|
22
|
+
sys.path.insert(0, PROJECT_ROOT)
|
|
23
|
+
|
|
24
|
+
from src.adapter_core import (
|
|
25
|
+
TOKENSAFE_DIRECTIVES,
|
|
26
|
+
compact_for_injection,
|
|
27
|
+
guard_command,
|
|
28
|
+
guard_read,
|
|
29
|
+
guard_write,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
AGENT = "kimi_code"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def handle(event: str, payload: dict) -> dict:
|
|
36
|
+
session_id = str(payload.get("session_id") or "") or f"hook_{AGENT}"
|
|
37
|
+
|
|
38
|
+
if event == "SessionStart":
|
|
39
|
+
extra = TOKENSAFE_DIRECTIVES
|
|
40
|
+
try:
|
|
41
|
+
from src.version_checker import VersionChecker
|
|
42
|
+
VersionChecker.notify_os_update_background()
|
|
43
|
+
except Exception:
|
|
44
|
+
pass
|
|
45
|
+
try:
|
|
46
|
+
from src.metrics import MetricsTracker
|
|
47
|
+
from src.license_manager import LicenseManager
|
|
48
|
+
quota = LicenseManager.check_quota(MetricsTracker())
|
|
49
|
+
if quota.get("warning"):
|
|
50
|
+
extra = f"{extra}\n\n{quota['warning']}"
|
|
51
|
+
except Exception:
|
|
52
|
+
pass
|
|
53
|
+
try:
|
|
54
|
+
from src.mistakes import MistakesLedger
|
|
55
|
+
guard = MistakesLedger.get_guard_prompt(project_root=str(payload.get("cwd") or os.getcwd()))
|
|
56
|
+
if guard:
|
|
57
|
+
extra = f"{extra}\n\n{guard}"
|
|
58
|
+
except Exception:
|
|
59
|
+
pass
|
|
60
|
+
return {
|
|
61
|
+
"hookSpecificOutput": {
|
|
62
|
+
"hookEventName": "SessionStart",
|
|
63
|
+
"additionalContext": extra,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if event == "UserPromptSubmit":
|
|
68
|
+
prompt = str(payload.get("prompt") or "")
|
|
69
|
+
parts = []
|
|
70
|
+
quota = {"is_quota_exceeded": False, "warning": None}
|
|
71
|
+
tracker = None
|
|
72
|
+
try:
|
|
73
|
+
from src.metrics import MetricsTracker
|
|
74
|
+
from src.license_manager import LicenseManager
|
|
75
|
+
tracker = MetricsTracker()
|
|
76
|
+
quota = LicenseManager.check_quota(tracker)
|
|
77
|
+
except Exception:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
if quota.get("is_quota_exceeded"):
|
|
81
|
+
try:
|
|
82
|
+
from src.license_manager import LicenseManager
|
|
83
|
+
if LicenseManager.should_emit_quota_banner(tracker, session_id, every_n_turns=5) and quota.get("warning"):
|
|
84
|
+
parts.append(quota["warning"])
|
|
85
|
+
except Exception:
|
|
86
|
+
pass
|
|
87
|
+
if parts:
|
|
88
|
+
return {
|
|
89
|
+
"hookSpecificOutput": {
|
|
90
|
+
"hookEventName": "UserPromptSubmit",
|
|
91
|
+
"additionalContext": "\n\n".join(parts),
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {}
|
|
95
|
+
|
|
96
|
+
context, meta = compact_for_injection(prompt, AGENT, session_id)
|
|
97
|
+
if context and meta.get("compacted"):
|
|
98
|
+
parts.append(
|
|
99
|
+
f"{context}\n"
|
|
100
|
+
f"(TokenSafe: compacted ~{meta['saved_tokens']} prompt tokens, "
|
|
101
|
+
f"-{meta.get('reduction_pct', 0)}% — original intent preserved.)"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if parts:
|
|
105
|
+
return {
|
|
106
|
+
"hookSpecificOutput": {
|
|
107
|
+
"hookEventName": "UserPromptSubmit",
|
|
108
|
+
"additionalContext": "\n\n".join(parts),
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return {}
|
|
112
|
+
|
|
113
|
+
if event == "PreToolUse":
|
|
114
|
+
tool = str(payload.get("tool_name") or "")
|
|
115
|
+
tool_input = payload.get("tool_input")
|
|
116
|
+
if not isinstance(tool_input, dict):
|
|
117
|
+
tool_input = {}
|
|
118
|
+
|
|
119
|
+
if tool in ("Bash", "Shell", "bash"):
|
|
120
|
+
command = str(tool_input.get("command") or "")
|
|
121
|
+
verdict = guard_command(command, AGENT, session_id, cwd=str(payload.get("cwd") or ""))
|
|
122
|
+
if verdict["decision"] == "deny":
|
|
123
|
+
return {
|
|
124
|
+
"hookSpecificOutput": {
|
|
125
|
+
"hookEventName": "PreToolUse",
|
|
126
|
+
"permissionDecision": "deny",
|
|
127
|
+
"permissionDecisionReason": verdict["reason"],
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if verdict["decision"] == "ask":
|
|
131
|
+
return {
|
|
132
|
+
"hookSpecificOutput": {
|
|
133
|
+
"hookEventName": "PreToolUse",
|
|
134
|
+
"permissionDecision": "ask",
|
|
135
|
+
"permissionDecisionReason": verdict["reason"],
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
elif tool in ("Write", "write_file", "replace_file_content"):
|
|
140
|
+
file_path = str(tool_input.get("file_path") or tool_input.get("Path") or tool_input.get("path") or "")
|
|
141
|
+
content = tool_input.get("content") or tool_input.get("Content") or tool_input.get("file_text") or ""
|
|
142
|
+
append = bool(tool_input.get("append") or tool_input.get("Append") or False)
|
|
143
|
+
verdict = guard_write(file_path, str(content or ""), append, AGENT, session_id)
|
|
144
|
+
if verdict["decision"] == "deny":
|
|
145
|
+
return {
|
|
146
|
+
"hookSpecificOutput": {
|
|
147
|
+
"hookEventName": "PreToolUse",
|
|
148
|
+
"permissionDecision": "deny",
|
|
149
|
+
"permissionDecisionReason": verdict["reason"],
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if verdict["decision"] == "ask":
|
|
153
|
+
return {
|
|
154
|
+
"hookSpecificOutput": {
|
|
155
|
+
"hookEventName": "PreToolUse",
|
|
156
|
+
"permissionDecision": "ask",
|
|
157
|
+
"permissionDecisionReason": verdict["reason"],
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
elif tool in ("Read", "read_file", "view_file"):
|
|
162
|
+
file_path = str(tool_input.get("file_path") or tool_input.get("path") or tool_input.get("Path") or "")
|
|
163
|
+
verdict = guard_read(file_path, AGENT, session_id)
|
|
164
|
+
if verdict["decision"] == "deny":
|
|
165
|
+
return {
|
|
166
|
+
"hookSpecificOutput": {
|
|
167
|
+
"hookEventName": "PreToolUse",
|
|
168
|
+
"permissionDecision": "deny",
|
|
169
|
+
"permissionDecisionReason": verdict["reason"],
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {}
|
|
174
|
+
|
|
175
|
+
if event == "PostToolUse":
|
|
176
|
+
tool = str(payload.get("tool_name") or "")
|
|
177
|
+
compacted, orig, new = None, 0, 0
|
|
178
|
+
try:
|
|
179
|
+
from src.command_sanitizer import CommandSanitizer
|
|
180
|
+
res = CommandSanitizer.compact_tool_output(tool, payload.get("tool_response"))
|
|
181
|
+
if res:
|
|
182
|
+
compacted, orig, new = res
|
|
183
|
+
except Exception:
|
|
184
|
+
compacted = None
|
|
185
|
+
if compacted:
|
|
186
|
+
try:
|
|
187
|
+
from src.metrics import MetricsTracker
|
|
188
|
+
from src.tokenizer import count_tokens
|
|
189
|
+
MetricsTracker().record_event(
|
|
190
|
+
session_id=session_id,
|
|
191
|
+
event_type="TOOL_OUTPUT_COMPACT",
|
|
192
|
+
original_tokens=count_tokens(str(payload.get("tool_response") or "")),
|
|
193
|
+
optimized_tokens=count_tokens(compacted),
|
|
194
|
+
details={"agent": AGENT, "tool": tool, "chars": f"{orig}->{new}"},
|
|
195
|
+
)
|
|
196
|
+
except Exception:
|
|
197
|
+
pass
|
|
198
|
+
return {
|
|
199
|
+
"decision": "block",
|
|
200
|
+
"reason": (
|
|
201
|
+
f"[TokenSafe] {tool} output auto-compacted "
|
|
202
|
+
f"({orig:,} → {new:,} chars). Output summary:\n{compacted}"
|
|
203
|
+
),
|
|
204
|
+
}
|
|
205
|
+
return {}
|
|
206
|
+
|
|
207
|
+
return {}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def main():
|
|
211
|
+
try:
|
|
212
|
+
raw = sys.stdin.read()
|
|
213
|
+
payload = json.loads(raw) if raw.strip() else {}
|
|
214
|
+
if not isinstance(payload, dict):
|
|
215
|
+
payload = {}
|
|
216
|
+
except Exception:
|
|
217
|
+
print(json.dumps({}))
|
|
218
|
+
return
|
|
219
|
+
event = ""
|
|
220
|
+
try:
|
|
221
|
+
event = str(payload.get("hook_event_name") or "")
|
|
222
|
+
response = handle(event, payload)
|
|
223
|
+
if not isinstance(response, dict):
|
|
224
|
+
response = {}
|
|
225
|
+
except Exception:
|
|
226
|
+
response = {}
|
|
227
|
+
if event in ("UserPromptSubmit", "PreToolUse", "PostToolUse", "Stop"):
|
|
228
|
+
try:
|
|
229
|
+
from src.telemetry_sync import TelemetrySync
|
|
230
|
+
TelemetrySync.sync_background(throttle_seconds=0.0 if event == "Stop" else 20.0)
|
|
231
|
+
except Exception:
|
|
232
|
+
pass
|
|
233
|
+
print(json.dumps(response))
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
if __name__ == "__main__":
|
|
237
|
+
main()
|
package/kimi.plugin.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tokensafe",
|
|
3
|
+
"version": "4.1.8",
|
|
4
|
+
"description": "Your coding agent isn't getting dumber. Your context is just full of trash. Local context firewall & zero-loss runtime for Cursor, Claude Code, and autonomous agents.",
|
|
5
|
+
"homepage": "https://tokensafe.dev",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"logo": "https://tokensafe.dev/logo.png",
|
|
8
|
+
"icon": "https://tokensafe.dev/logo.png",
|
|
9
|
+
"iconUrl": "https://tokensafe.dev/logo.png",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "TokenSafe"
|
|
12
|
+
},
|
|
13
|
+
"interface": {
|
|
14
|
+
"displayName": "TokenSafe",
|
|
15
|
+
"shortDescription": "Stop coding agent context rot, destructive rewrites & secret leaks",
|
|
16
|
+
"developerName": "TokenSafe",
|
|
17
|
+
"websiteURL": "https://tokensafe.dev",
|
|
18
|
+
"logo": "https://tokensafe.dev/logo.png",
|
|
19
|
+
"iconUrl": "https://tokensafe.dev/logo.png"
|
|
20
|
+
},
|
|
21
|
+
"skills": [
|
|
22
|
+
"skills/token-optimizer"
|
|
23
|
+
],
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"tokensafe": {
|
|
26
|
+
"command": "python3",
|
|
27
|
+
"args": [
|
|
28
|
+
"src/mcp_server.py"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"hooks": [
|
|
33
|
+
{
|
|
34
|
+
"event": "SessionStart",
|
|
35
|
+
"command": "python3 hooks/kimi_hook.py",
|
|
36
|
+
"timeout": 10
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"event": "UserPromptSubmit",
|
|
40
|
+
"command": "python3 hooks/kimi_hook.py",
|
|
41
|
+
"timeout": 10
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"event": "PreToolUse",
|
|
45
|
+
"matcher": "Bash",
|
|
46
|
+
"command": "python3 hooks/kimi_hook.py",
|
|
47
|
+
"timeout": 10
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"event": "PreToolUse",
|
|
51
|
+
"matcher": "Write",
|
|
52
|
+
"command": "python3 hooks/kimi_hook.py",
|
|
53
|
+
"timeout": 10
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"event": "PreToolUse",
|
|
57
|
+
"matcher": "Read",
|
|
58
|
+
"command": "python3 hooks/kimi_hook.py",
|
|
59
|
+
"timeout": 10
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.8",
|
|
5
5
|
"description": "Your coding agent isn't getting dumber. Your context is just full of trash. Local context firewall & zero-loss runtime for Cursor, Claude Code, and autonomous agents.",
|
|
6
6
|
"main": "bin/tokensafe.js",
|
|
7
7
|
"bin": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"!src/mailer.py",
|
|
17
17
|
"!src/weekly_digest.py",
|
|
18
18
|
"!**/__pycache__/**",
|
|
19
|
+
"!hooks/__pycache__/**",
|
|
19
20
|
"!**/*.pyc",
|
|
20
21
|
"rules/",
|
|
21
22
|
"skills/",
|
|
@@ -24,7 +25,10 @@
|
|
|
24
25
|
"mcp_config.json",
|
|
25
26
|
"proto/",
|
|
26
27
|
"extensions/",
|
|
28
|
+
"assets/",
|
|
29
|
+
".codex-plugin/",
|
|
27
30
|
"plugin.json",
|
|
31
|
+
"kimi.plugin.json",
|
|
28
32
|
"server.json",
|
|
29
33
|
"README.md",
|
|
30
34
|
"LICENSE"
|
package/plugin.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"displayName": "TokenSafe",
|
|
4
|
-
"version": "4.1.
|
|
5
|
-
"description": "
|
|
6
|
-
"logo": "
|
|
4
|
+
"version": "4.1.8",
|
|
5
|
+
"description": "Your coding agent isn't getting dumber. Your context is just full of trash. Local context firewall & zero-loss runtime for Cursor, Claude Code, and autonomous agents.",
|
|
6
|
+
"logo": "https://tokensafe.dev/logo.png",
|
|
7
|
+
"developerName": "TokenSafe",
|
|
7
8
|
"author": {
|
|
8
|
-
"name": "
|
|
9
|
-
"url": "https://
|
|
9
|
+
"name": "TokenSafe",
|
|
10
|
+
"url": "https://tokensafe.dev"
|
|
10
11
|
},
|
|
11
12
|
"homepage": "https://tokensafe.dev",
|
|
12
13
|
"repository": {
|
package/rules/AGENTS.md
CHANGED
|
@@ -37,7 +37,7 @@ Execute the specified action directly based on these extracted parameters.
|
|
|
37
37
|
7. **Bounded Reads**: Never call `read_file` without `StartLine`/`EndLine` on files > 100 lines unless inspecting a skeleton.
|
|
38
38
|
8. **Directory Navigation**: Never run verbose `ls -la` or `ls -l`; use `tokensafe:list_dir(path=".", depth=2)` to inspect directory trees without permissions, timestamps, or lockfiles (-90% tokens). Supports relative subfolders (`path="src"`).
|
|
39
39
|
9. **Style & Design Tokens**: When inspecting CSS/SCSS/LESS/Tailwind, `tokensafe:smart_read_file` automatically preserves all design tokens (`:root`, `@theme`, CSS variables) in full while folding component selectors.
|
|
40
|
-
10. **Command Output Wrapping & Test Execution**: Run noisy commands and test suites via `tokensafe wrap '<command>'` or `tokensafe tests [cmd]`. Passing tests return a 1-line summary (`✓ PASS: ...`), and failures return focused failure blocks with full tracebacks preserved in stash.
|
|
40
|
+
10. **Command Output Wrapping & Test Execution**: Run noisy commands, builds, and test suites (`bun test`, `pytest`, `python -m unittest`, `vitest`, `jest`, `cargo test`, `go test`) via `tokensafe wrap '<command>'` or `tokensafe tests [cmd]`. Sanitization automatically strips `git push` progress animation frames (`--no-progress`), wraps `git commit` when pre-commit/husky hooks exist, and forces test runners into run-once mode. Passing tests return a 1-line summary (`✓ PASS: ...`), and failures return focused failure blocks with full tracebacks preserved in stash.
|
|
41
41
|
11. **Context Budget & Smart Compaction**: Before large multi-step tasks, call `tokensafe:context_budget(model=...)` to check window usage and Context Quality Score (Grade S-F). When it reports `warning`, `critical`, or Grade C/F, call `tokensafe:compact_conversation(transcript_path=...)` to fold past turns into a Consolidated State Ledger with a 3-line Post-Compaction Orientation Digest (Active Goal, Last State, Next Focus) before continuing.
|
|
42
42
|
12. **Vision Image Optimization (`optimize_image`)**: When handling screenshots or visual diagrams, call `tokensafe:optimize_image` or run `tokensafe optimize-image <file>` to downscale images exceeding 1024px (-50-75% vision tokens) while preserving original disk files.
|
|
43
43
|
13. **Superseded Output Pruning (`prune_superseded`)**: In long multi-turn sessions, prune obsolete intermediate file reads via `tokensafe:prune_superseded(transcript_path)` to free up context without losing history.
|
package/server.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "dev.tokensafe/tokensafe",
|
|
4
4
|
"title": "TokenSafe",
|
|
5
|
-
"description": "
|
|
6
|
-
"version": "4.1.
|
|
5
|
+
"description": "Your coding agent isn't getting dumber. Your context is just full of trash. Local context firewall & zero-loss runtime for Cursor, Claude Code, and autonomous agents.",
|
|
6
|
+
"version": "4.1.8",
|
|
7
7
|
"websiteUrl": "https://tokensafe.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/tokensafe-dev/tokensafe",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"registryType": "npm",
|
|
31
31
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
32
32
|
"identifier": "tokensafe",
|
|
33
|
-
"version": "4.1.
|
|
33
|
+
"version": "4.1.8",
|
|
34
34
|
"runtimeHint": "npx",
|
|
35
35
|
"transport": {
|
|
36
36
|
"type": "stdio"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"registryType": "pypi",
|
|
47
47
|
"registryBaseUrl": "https://pypi.org",
|
|
48
48
|
"identifier": "tokensafe",
|
|
49
|
-
"version": "4.1.
|
|
49
|
+
"version": "4.1.8",
|
|
50
50
|
"runtimeHint": "uvx",
|
|
51
51
|
"transport": {
|
|
52
52
|
"type": "stdio"
|
|
@@ -60,8 +60,9 @@ folds multi-turn conversation history, slices verbose tool outputs, and guards a
|
|
|
60
60
|
- Eliminate conversational preambles, courtesy fillers, and trailing sign-offs.
|
|
61
61
|
- Never reprint full unmodified files or lengthy boilerplate; cite line ranges and provide targeted diffs.
|
|
62
62
|
|
|
63
|
-
11. **COMPACT TEST EXECUTION**:
|
|
64
|
-
- Run unit tests with concise flags or via `tokensafe tests [cmd]`
|
|
63
|
+
11. **COMPACT TEST EXECUTION & PIPELINE SANITIZATION**:
|
|
64
|
+
- Run unit tests with concise flags or via `tokensafe wrap '<cmd>'` or `tokensafe tests [cmd]`. Native support for `bun test`, `pytest`, `python -m unittest`, `vitest`, `jest`, `cargo test`, and `go test` collapses passing test suites into a single-line summary (`✓ PASS: ...`) rather than flooding `Messages` history with hundreds of verbose log lines. Full traceback is strictly preserved on failure.
|
|
65
|
+
- Commands like `git push` automatically strip interactive object-counting progress spam (`--no-progress`), and `git commit` is wrapped when pre-commit/husky hooks exist.
|
|
65
66
|
|
|
66
67
|
---
|
|
67
68
|
|
|
@@ -82,7 +83,7 @@ Quick pointers:
|
|
|
82
83
|
- Bundle: `tokensafe:smart_bundle(targets=[{path, symbol}])` — 3-8 related symbols across files in one call, shared imports deduplicated.
|
|
83
84
|
- Navigate: `tokensafe:get_architecture_graph(project_path)` / `tokensafe:get_api_surface(project_path)`.
|
|
84
85
|
- Directory: `tokensafe:list_dir(path, depth=2)` — clean tree, never verbose `ls -la`.
|
|
85
|
-
- Terminal: `tokensafe:sanitize_command(command, cwd)` or run via `tokensafe wrap '<cmd>'
|
|
86
|
+
- Terminal: `tokensafe:sanitize_command(command, cwd)` or run via `tokensafe wrap '<cmd>'` — rewrites git push (--no-progress), wraps git commit hooks, and folds test suites (bun, python unittest/pytest, vitest, jest, cargo, go) to 1-line summaries.
|
|
86
87
|
- Context: `tokensafe:compact_conversation(transcript_path)` / `tokensafe:context_budget`.
|
|
87
88
|
- Vision: `tokensafe:optimize_image(image_path, max_edge=1024)` — downscale images >1024px (-50-75% vision tokens).
|
|
88
89
|
- Prune Reads: `tokensafe:prune_superseded(transcript_path)` — drops obsolete intermediate file reads (-30-40% context).
|
|
@@ -28,7 +28,7 @@ tokensafe guard "<command>" # Pre-flight check command safety (rm, secrets, gr
|
|
|
28
28
|
tokensafe guard audit [path] # Recursively audit project files for security violations
|
|
29
29
|
tokensafe doctor [--cleanup] # Audit MCP tool overhead, token tax & clean competitor conflicts
|
|
30
30
|
tokensafe expand-ref <hash> # Restore original raw content of any folded block by its 8-char hash
|
|
31
|
-
tokensafe wrap "<cmd>" # Run noisy command with compact output folding (e.g. tests, tsc, builds)
|
|
31
|
+
tokensafe wrap "<cmd>" # Run noisy command with compact output folding (e.g. bun/python/jest tests, git commit hooks, tsc, builds)
|
|
32
32
|
tokensafe web <url> # Fetch web page/docs and print clean compact Markdown
|
|
33
33
|
tokensafe optimize-image <img># Downscale oversized screenshot to max 1024px (-50-75% vision tokens)
|
|
34
34
|
tokensafe prune-superseded <t># Prune outdated intermediate reads from conversation transcript
|
|
@@ -12,7 +12,7 @@ All tools are exposed via Model Context Protocol (stdio JSON-RPC 2.0).
|
|
|
12
12
|
| `tokensafe:list_dir` | Token-efficient directory tree without lockfiles, timestamps, or ignored folders (node_modules, .git, dist, .env). Replaces `ls -la`. | **-90%** vs verbose `ls` |
|
|
13
13
|
| `tokensafe:get_architecture_graph` | Computes dependency topology, hub centrality, and identifies top God Nodes for `project_path`. | **~200 tokens** (replaces 50k crawl) |
|
|
14
14
|
| `tokensafe:get_api_surface` | Generates a compact markdown map of all exported types, interfaces, and classes. | **~500 tokens** for entire project |
|
|
15
|
-
| `tokensafe:sanitize_command` | Per-stage command rewrites: lockfile diffs, unbounded `git log`/`git show`/`git blame`/`rg`, docker/kubectl log caps, quiet npm/pip installs, bounded `cat`/`curl` output. Compound commands (`a && b ; c`) are optimized per stage
|
|
15
|
+
| `tokensafe:sanitize_command` | Per-stage command rewrites: lockfile diffs, unbounded `git log`/`git show`/`git blame`/`rg`, docker/kubectl log caps, quiet npm/pip installs, bounded `cat`/`curl` output, `git push` object-counting strip (`--no-progress`), and `git commit` hook wrapping. Compound commands (`a && b ; c`) are optimized per stage. Test commands (`bun test`, `pytest`, `python -m unittest`, `vitest`, `jest`) are wrapped or forced into run-once mode (`CI=true`, `--watch=false`, `--forceExit`) so passing suites emit a clean 1-line summary and agents never hang on watch mode. Pass optional `cwd` to identify runners behind opaque `yarn/npm test` scripts. | Saves **10k-50k tokens** per run |
|
|
16
16
|
| `tokensafe:slice_diff` | Slices unified git diffs, eliminating lockfiles and minimizing hunk context lines. | **-50% to -80%** diff size |
|
|
17
17
|
| `tokensafe:compress_prompt` | Compresses verbose user instructions into lean TOCP S-expressions via DeepSeek/Regex. | **-40% to -65%** prompt tokens |
|
|
18
18
|
| `tokensafe:compact_conversation` | On-demand context compaction: folds a long JSONL session transcript into a lean Consolidated State Ledger with a 3-line Post-Compaction Orientation Digest (`transcript_path`, optional `invocation_num`). Preserves flow instantly without post-compaction amnesia. | **-80% to -95%** history tokens |
|
package/src/adapter_core.py
CHANGED
|
@@ -79,7 +79,7 @@ _INFINITE_PATTERNS = [
|
|
|
79
79
|
r"\bdocker\s+attach\b",
|
|
80
80
|
# vitest runs an interactive watcher unless the `run` subcommand is given
|
|
81
81
|
r"\bvitest\b(?![^|;&]*\brun\b)",
|
|
82
|
-
r"\b(?:jest|vitest)\b[^|;&]*--watch\b",
|
|
82
|
+
r"\b(?:jest|vitest|bun)\b[^|;&]*--watch\b",
|
|
83
83
|
]
|
|
84
84
|
|
|
85
85
|
# Lockfiles/junk that must never be dumped into an agent context.
|
package/src/command_sanitizer.py
CHANGED
|
@@ -227,6 +227,42 @@ class CommandSanitizer:
|
|
|
227
227
|
cmd_tok = os.path.basename(tokens[idx])
|
|
228
228
|
return cmd_tok, tokens[idx + 1 :]
|
|
229
229
|
|
|
230
|
+
@classmethod
|
|
231
|
+
def _has_git_hooks(cls, cwd: Optional[str] = None) -> bool:
|
|
232
|
+
"""Checks if pre-commit hooks exist in cwd or git root."""
|
|
233
|
+
base = os.path.abspath(os.path.expanduser(cwd)) if cwd else os.getcwd()
|
|
234
|
+
cur = base
|
|
235
|
+
for _ in range(5):
|
|
236
|
+
if os.path.isfile(os.path.join(cur, ".husky", "pre-commit")):
|
|
237
|
+
return True
|
|
238
|
+
if os.path.isfile(os.path.join(cur, ".git", "hooks", "pre-commit")):
|
|
239
|
+
return True
|
|
240
|
+
if os.path.isfile(os.path.join(cur, ".pre-commit-config.yaml")):
|
|
241
|
+
return True
|
|
242
|
+
if os.path.isfile(os.path.join(cur, "lefthook.yml")):
|
|
243
|
+
return True
|
|
244
|
+
parent = os.path.dirname(cur)
|
|
245
|
+
if parent == cur:
|
|
246
|
+
break
|
|
247
|
+
cur = parent
|
|
248
|
+
return False
|
|
249
|
+
|
|
250
|
+
@classmethod
|
|
251
|
+
def _is_tokensafe_available(cls) -> bool:
|
|
252
|
+
"""Returns True if tokensafe executable is in PATH or known install locations."""
|
|
253
|
+
import shutil
|
|
254
|
+
if shutil.which("tokensafe"):
|
|
255
|
+
return True
|
|
256
|
+
for candidate in (
|
|
257
|
+
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "bin", "tokensafe"),
|
|
258
|
+
os.path.expanduser("~/.tokensafe/bin/tokensafe"),
|
|
259
|
+
os.path.expanduser("~/.local/bin/tokensafe"),
|
|
260
|
+
"/usr/local/bin/tokensafe",
|
|
261
|
+
):
|
|
262
|
+
if os.path.exists(candidate):
|
|
263
|
+
return True
|
|
264
|
+
return False
|
|
265
|
+
|
|
230
266
|
@classmethod
|
|
231
267
|
def _optimize_stage(cls, stage: str, cwd: Optional[str] = None) -> Optional[Tuple[str, int, str, Optional[Tuple[str, int]]]]:
|
|
232
268
|
"""
|
|
@@ -303,11 +339,34 @@ class CommandSanitizer:
|
|
|
303
339
|
if "-L" not in sub_args and not any(a.startswith("-L") for a in sub_args):
|
|
304
340
|
return stage, 1500, "Capped git blame output", cls._CAP_LINES_200
|
|
305
341
|
|
|
342
|
+
# git push: eliminate interactive progress animation spam (Counting objects, Writing objects)
|
|
343
|
+
elif subcmd == "push":
|
|
344
|
+
if "--no-progress" not in sub_args and "-q" not in sub_args and "--quiet" not in sub_args:
|
|
345
|
+
new_stage = re.sub(r"\b(git(?:\s+-C\s+\S+)?\s+push)\b", r"\1 --no-progress", stage, count=1)
|
|
346
|
+
return new_stage, 800, "Added --no-progress to git push to eliminate object counting animation spam", None
|
|
347
|
+
|
|
348
|
+
# git commit: wrap with tokensafe wrap when hooks exist and message is provided
|
|
349
|
+
elif subcmd == "commit":
|
|
350
|
+
has_msg = any(
|
|
351
|
+
a in ("-m", "--message", "-F", "--file", "--no-edit")
|
|
352
|
+
or a.startswith(("-m=", "--message=", "-F=", "--file="))
|
|
353
|
+
for a in sub_args
|
|
354
|
+
)
|
|
355
|
+
if has_msg and cls._has_git_hooks(cwd) and cls._is_tokensafe_available() and not cls._TOKENSAFE_WRAP_RE.search(stage):
|
|
356
|
+
wrapped = f"tokensafe wrap {shlex.quote(stage)}"
|
|
357
|
+
return wrapped, 2500, "Wrapped git commit with tokensafe wrap to compact pre-commit hooks and test output", None
|
|
358
|
+
|
|
306
359
|
# pytest (or python -m pytest): compact quiet traceback
|
|
307
360
|
if cmd_tok == "pytest" or (cmd_tok.startswith("python") and "-m" in cmd_args and "pytest" in cmd_args):
|
|
308
361
|
if "--tb=" not in stage and "-q" not in cmd_args and "--quiet" not in cmd_args:
|
|
309
362
|
return f"{stage} -q --tb=short", 800, "Applied short traceback to pytest", None
|
|
310
363
|
|
|
364
|
+
# python -m unittest (or python3 -m unittest): wrap with tokensafe wrap to fold test noise
|
|
365
|
+
if cmd_tok.startswith("python") and "-m" in cmd_args and "unittest" in cmd_args:
|
|
366
|
+
if cls._is_tokensafe_available() and not cls._TOKENSAFE_WRAP_RE.search(stage):
|
|
367
|
+
wrapped = f"tokensafe wrap {shlex.quote(stage)}"
|
|
368
|
+
return wrapped, 2000, "Wrapped python unittest with tokensafe wrap to compact test results into one-line summary", None
|
|
369
|
+
|
|
311
370
|
# cargo test: quiet test runner by default when not specified
|
|
312
371
|
if cmd_tok == "cargo" and cmd_args[:1] == ["test"]:
|
|
313
372
|
if "--quiet" not in stage and "-q" not in stage and "--" not in stage:
|
|
@@ -425,9 +484,13 @@ class CommandSanitizer:
|
|
|
425
484
|
runner = "vitest"
|
|
426
485
|
elif cls._JEST_RE.match(stage) or cls._JEST_SCRIPT_RE.search(stage):
|
|
427
486
|
runner = "jest"
|
|
487
|
+
elif (cmd_tok == "bun" and cmd_args[:1] == ["test"]) or (cmd_tok in ("bunx",) and cmd_args[1:2] == ["test"]):
|
|
488
|
+
runner = "bun"
|
|
428
489
|
elif cls._PKG_MANAGER_TEST_RE.match(cls._strip_cmd_prefix(stage)):
|
|
429
490
|
if cls._JEST_FINGERPRINT_RE.search(stage):
|
|
430
491
|
runner = "jest"
|
|
492
|
+
elif cls._strip_cmd_prefix(stage).startswith("bun "):
|
|
493
|
+
runner = "bun"
|
|
431
494
|
else:
|
|
432
495
|
script_runner = cls._peek_test_script_runner(cwd)
|
|
433
496
|
runner = {"jest": "script-jest", "vitest": "script-vitest"}.get(script_runner, "generic")
|
|
@@ -438,6 +501,21 @@ class CommandSanitizer:
|
|
|
438
501
|
reasons: List[str] = []
|
|
439
502
|
saved = 0
|
|
440
503
|
|
|
504
|
+
if runner == "bun":
|
|
505
|
+
if cls._BARE_WATCH_RE.search(new_stage):
|
|
506
|
+
new_stage = cls._BARE_WATCH_RE.sub("", new_stage)
|
|
507
|
+
reasons.append("Dropped bare --watch from bun test command")
|
|
508
|
+
saved += 300
|
|
509
|
+
if not re.search(r"\bCI=", new_stage):
|
|
510
|
+
new_stage = f"CI=true {new_stage}"
|
|
511
|
+
saved += 300
|
|
512
|
+
reasons.append("Prepended CI=true for bun test run-once mode")
|
|
513
|
+
if cls._is_tokensafe_available() and not cls._TOKENSAFE_WRAP_RE.search(new_stage):
|
|
514
|
+
new_stage = f"tokensafe wrap {shlex.quote(new_stage)}"
|
|
515
|
+
saved += 2000
|
|
516
|
+
reasons.append("Wrapped bun test with tokensafe wrap to fold passing tests into compact summary")
|
|
517
|
+
return new_stage, saved, "; ".join(reasons), None
|
|
518
|
+
|
|
441
519
|
if runner in ("vitest", "script-vitest"):
|
|
442
520
|
if cls._BARE_WATCH_RE.search(new_stage):
|
|
443
521
|
new_stage = cls._BARE_WATCH_RE.sub("", new_stage)
|
|
@@ -593,21 +671,7 @@ class CommandSanitizer:
|
|
|
593
671
|
if not is_build:
|
|
594
672
|
return None
|
|
595
673
|
|
|
596
|
-
|
|
597
|
-
import shutil
|
|
598
|
-
has_tokensafe = bool(shutil.which("tokensafe"))
|
|
599
|
-
if not has_tokensafe:
|
|
600
|
-
for candidate in (
|
|
601
|
-
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "bin", "tokensafe"),
|
|
602
|
-
os.path.expanduser("~/.tokensafe/bin/tokensafe"),
|
|
603
|
-
os.path.expanduser("~/.local/bin/tokensafe"),
|
|
604
|
-
"/usr/local/bin/tokensafe"
|
|
605
|
-
):
|
|
606
|
-
if os.path.exists(candidate):
|
|
607
|
-
has_tokensafe = True
|
|
608
|
-
break
|
|
609
|
-
|
|
610
|
-
if not has_tokensafe:
|
|
674
|
+
if not cls._is_tokensafe_available():
|
|
611
675
|
return None
|
|
612
676
|
|
|
613
677
|
wrapped = f"tokensafe wrap {shlex.quote(stage)}"
|
|
@@ -755,6 +819,15 @@ class CommandSanitizer:
|
|
|
755
819
|
if line.startswith("ok \t") or line.startswith("PASS"):
|
|
756
820
|
return f"PASS: {line}"
|
|
757
821
|
|
|
822
|
+
# 6. bun test check
|
|
823
|
+
for line in reversed(lines):
|
|
824
|
+
if "test files passed in" in line:
|
|
825
|
+
return f"PASS: {line} (bun test)"
|
|
826
|
+
if line.startswith("Ran ") and "tests across" in line and "file" in line:
|
|
827
|
+
return f"PASS: {line} (bun test)"
|
|
828
|
+
if re.search(r"^\d+\s+pass\b", line):
|
|
829
|
+
return f"PASS: {line} (bun test)"
|
|
830
|
+
|
|
758
831
|
# Fallback for verbose outputs: if > 12 lines, cap to first line + last line
|
|
759
832
|
if len(lines) > 12:
|
|
760
833
|
return f"PASS: {lines[0]} ... {lines[-1]} (exit code 0)"
|
package/src/installer.py
CHANGED
|
@@ -53,7 +53,7 @@ UNIFIED_TOKENSAFE_RULE = (
|
|
|
53
53
|
"5. **Architecture Discovery**: Always call `tokensafe:get_architecture_graph(project_path='.')` before exploratory multi-file reading (`project_path` defaults to active workspace). Returns project God Nodes and key dependency hubs in < 250 tokens without file crawling.\n"
|
|
54
54
|
"6. **API Surface Map**: Use `tokensafe:get_api_surface(project_path='.')` to get all exported classes, types, and interfaces in a single markdown map without crawling files.\n"
|
|
55
55
|
"7. **No Unconstrained Shell Grep/Find & No Verbose ls -la**: Strictly avoid running raw recursive grep/find across projects. Never run verbose `ls -la` or `ls -l`; use `tokensafe:list_dir(path='.', depth=2)` to inspect directory trees in clean markdown without permissions, timestamps, or lockfiles (-90% tokens). Supports relative subfolders (`path='src'`).\n"
|
|
56
|
-
"8. **Command Sanitization, Build Compaction & Compact Tests**: Use `sanitize_command` on high-output terminal commands (`git diff/log/show/blame`, `rg`, `find`, `grep`, `docker`/`kubectl logs`, `npm`/`pip install`, `cat` of lockfiles, `curl`, and build/typecheck commands like `npm run build`, `vite build`, `next build`, `cargo build`, `tsc`, `tsc --noEmit`, `npm run typecheck`, `npx eslint`) — compound commands (`a && b ; c`) are rewritten per stage. Run noisy commands, builds, and test suites via `tokensafe wrap '<command>'` or `tokensafe tests [cmd]` (clean
|
|
56
|
+
"8. **Command Sanitization, Build Compaction & Compact Tests**: Use `sanitize_command` on high-output terminal commands (`git diff/log/show/blame`, `git push` --no-progress, `git commit` hook protection, `rg`, `find`, `grep`, `docker`/`kubectl logs`, `npm`/`pip install`, `cat` of lockfiles, `curl`, and build/typecheck commands like `npm run build`, `vite build`, `next build`, `cargo build`, `tsc`, `tsc --noEmit`, `npm run typecheck`, `npx eslint`) — compound commands (`a && b ; c`) are rewritten per stage. Run noisy commands, builds, and test suites (`bun test`, `pytest`, `python -m unittest`, `vitest`, `jest`, `cargo test`, `go test`) via `tokensafe wrap '<command>'` or `tokensafe tests [cmd]` (clean 1-line build/pass summary, full traceback/compiler error only on failure) instead of raw verbose test crawls; never leave `vitest`/`jest`/`bun` in watch mode — pass the optional `cwd` to `sanitize_command` for test commands so the package.json peek can identify the runner behind opaque `yarn/npm test` scripts.\n"
|
|
57
57
|
"9. **Styles & Design Token Preservation**: When inspecting CSS, SCSS, LESS, or Tailwind, `smart_read_file` automatically preserves all design tokens (`:root`, `@theme`, CSS variables) in full while folding component selectors to protect project design integrity.\n"
|
|
58
58
|
"10. **Context Budget & Smart Compaction**: Before large multi-step tasks, call `tokensafe:context_budget(model=...)` to inspect window usage and Context Quality Score (Grade S-F); when it reports `warning` or `critical` (or Grade C/F), call `tokensafe:compact_conversation(transcript_path=...)` to fold history into a State Ledger with a 3-line Post-Compaction Orientation Digest before continuing.\n"
|
|
59
59
|
"11. **Secret Leak Prevention Directive (Zero Hardcoded Fallbacks)**:\n"
|
|
@@ -70,7 +70,7 @@ UNIFIED_TOKENSAFE_RULE = (
|
|
|
70
70
|
POINTER_RULE = (
|
|
71
71
|
"## TOKENSAFE GRAPH-FIRST OPTIMIZATION PROTOCOL\n"
|
|
72
72
|
"The full 12-point protocol is installed globally in the agent-level instructions "
|
|
73
|
-
"(~/.zcode/AGENTS.md, ~/.claude/CLAUDE.md, ~/.codex/AGENTS.md) and applies to this project. "
|
|
73
|
+
"(~/.zcode/AGENTS.md, ~/.claude/CLAUDE.md, ~/.codex/AGENTS.md, ~/.kimi-code/AGENTS.md) and applies to this project. "
|
|
74
74
|
"Core rules: never raw grep/find or `ls -la` — use `tokensafe:scoped_search`, "
|
|
75
75
|
"`tokensafe:smart_read_file(path, symbol)`, `tokensafe:smart_bundle` and `tokensafe:list_dir`; "
|
|
76
76
|
"sanitize high-output commands via `tokensafe:sanitize_command`; check `tokensafe:context_budget` (Grade S-F) "
|
|
@@ -146,6 +146,16 @@ AGENTS_REGISTRY = {
|
|
|
146
146
|
"plugin_path": os.path.join(HOME, ".zcode", "cli", "plugins", "tokensafe"),
|
|
147
147
|
"agents_md_path": os.path.join(HOME, ".zcode", "AGENTS.md"),
|
|
148
148
|
"detect_path": os.path.join(HOME, ".zcode")
|
|
149
|
+
},
|
|
150
|
+
"kimi": {
|
|
151
|
+
"name": "Kimi Code",
|
|
152
|
+
"type": "kimi_plugin",
|
|
153
|
+
"config_path": os.path.join(HOME, ".kimi-code", "mcp.json"),
|
|
154
|
+
"installed_json_path": os.path.join(HOME, ".kimi-code", "plugins", "installed.json"),
|
|
155
|
+
"managed_plugin_path": os.path.join(HOME, ".kimi-code", "plugins", "managed", "tokensafe"),
|
|
156
|
+
"skills_path": os.path.join(HOME, ".kimi-code", "skills", "token-optimizer"),
|
|
157
|
+
"agents_md_path": os.path.join(HOME, ".kimi-code", "AGENTS.md"),
|
|
158
|
+
"detect_path": os.path.join(HOME, ".kimi-code")
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
161
|
|
|
@@ -161,6 +171,12 @@ class AgentInstaller:
|
|
|
161
171
|
# Fallback for cursor / windsurf on macOS
|
|
162
172
|
if not is_present and key == "cursor":
|
|
163
173
|
is_present = os.path.exists(os.path.join(HOME, "Library", "Application Support", "Cursor"))
|
|
174
|
+
if not is_present and key == "kimi":
|
|
175
|
+
is_present = (
|
|
176
|
+
os.path.exists("/Applications/Kimi Code.app")
|
|
177
|
+
or os.path.exists(os.path.join(HOME, "Applications", "Kimi Code.app"))
|
|
178
|
+
or shutil.which("kimi") is not None
|
|
179
|
+
)
|
|
164
180
|
detected[key] = {
|
|
165
181
|
**info,
|
|
166
182
|
"installed": is_present
|
|
@@ -211,11 +227,62 @@ class AgentInstaller:
|
|
|
211
227
|
Codex has no lifecycle hooks (MCP + AGENTS.md remain the integration)."""
|
|
212
228
|
if agent_key == "codex":
|
|
213
229
|
return False, "Codex CLI has no lifecycle hooks — MCP + AGENTS.md stay the integration"
|
|
214
|
-
if agent_key not in ("claude_code", "cursor"):
|
|
230
|
+
if agent_key not in ("claude_code", "cursor", "kimi"):
|
|
215
231
|
return False, "hooks not applicable for this agent"
|
|
216
232
|
|
|
217
233
|
claude_cmd = cls._tokensafe_hook_command("claude_code_hook.py")
|
|
218
234
|
cursor_cmd = cls._tokensafe_hook_command("cursor_hook.py")
|
|
235
|
+
kimi_cmd = cls._tokensafe_hook_command("kimi_hook.py")
|
|
236
|
+
|
|
237
|
+
if agent_key == "kimi":
|
|
238
|
+
config_file = os.path.join(HOME, ".kimi-code", "config.toml")
|
|
239
|
+
os.makedirs(os.path.dirname(config_file), exist_ok=True)
|
|
240
|
+
content = ""
|
|
241
|
+
if os.path.exists(config_file):
|
|
242
|
+
try:
|
|
243
|
+
shutil.copy2(config_file, f"{config_file}.backup")
|
|
244
|
+
except Exception:
|
|
245
|
+
pass
|
|
246
|
+
try:
|
|
247
|
+
with open(config_file, "r", encoding="utf-8") as f:
|
|
248
|
+
content = f.read()
|
|
249
|
+
except Exception:
|
|
250
|
+
pass
|
|
251
|
+
|
|
252
|
+
if "kimi_hook.py" in content:
|
|
253
|
+
return True, "TokenSafe Kimi Code hooks already registered in config.toml"
|
|
254
|
+
|
|
255
|
+
toml_hook_cmd = json.dumps(kimi_cmd)
|
|
256
|
+
hook_sections = (
|
|
257
|
+
f'\n# TokenSafe Lifecycle Hooks\n'
|
|
258
|
+
f'[[hooks]]\n'
|
|
259
|
+
f'event = "SessionStart"\n'
|
|
260
|
+
f'command = {toml_hook_cmd}\n'
|
|
261
|
+
f'timeout = 10\n\n'
|
|
262
|
+
f'[[hooks]]\n'
|
|
263
|
+
f'event = "UserPromptSubmit"\n'
|
|
264
|
+
f'command = {toml_hook_cmd}\n'
|
|
265
|
+
f'timeout = 10\n\n'
|
|
266
|
+
f'[[hooks]]\n'
|
|
267
|
+
f'event = "PreToolUse"\n'
|
|
268
|
+
f'matcher = "Bash"\n'
|
|
269
|
+
f'command = {toml_hook_cmd}\n'
|
|
270
|
+
f'timeout = 10\n\n'
|
|
271
|
+
f'[[hooks]]\n'
|
|
272
|
+
f'event = "PreToolUse"\n'
|
|
273
|
+
f'matcher = "Write"\n'
|
|
274
|
+
f'command = {toml_hook_cmd}\n'
|
|
275
|
+
f'timeout = 10\n\n'
|
|
276
|
+
f'[[hooks]]\n'
|
|
277
|
+
f'event = "PreToolUse"\n'
|
|
278
|
+
f'matcher = "Read"\n'
|
|
279
|
+
f'command = {toml_hook_cmd}\n'
|
|
280
|
+
f'timeout = 10\n'
|
|
281
|
+
)
|
|
282
|
+
content = (content.rstrip() + "\n" + hook_sections) if content.strip() else hook_sections.lstrip()
|
|
283
|
+
with open(config_file, "w", encoding="utf-8") as f:
|
|
284
|
+
f.write(content)
|
|
285
|
+
return True, "hooks registered in ~/.kimi-code/config.toml (SessionStart + UserPromptSubmit + PreToolUse Bash/Write/Read)"
|
|
219
286
|
|
|
220
287
|
if agent_key == "claude_code":
|
|
221
288
|
config_file = os.path.join(HOME, ".claude", "settings.json")
|
|
@@ -834,6 +901,71 @@ WantedBy=default.target
|
|
|
834
901
|
|
|
835
902
|
return True, f"Configured MCP, Plugin, Skill & AGENTS.md in {config_file}"
|
|
836
903
|
|
|
904
|
+
elif info["type"] == "kimi_plugin":
|
|
905
|
+
mcp_file = info.get("config_path")
|
|
906
|
+
if mcp_file:
|
|
907
|
+
os.makedirs(os.path.dirname(mcp_file), exist_ok=True)
|
|
908
|
+
data, err = cls._load_json_with_backup(mcp_file)
|
|
909
|
+
if err or data is None:
|
|
910
|
+
data = {}
|
|
911
|
+
if "mcpServers" not in data or not isinstance(data["mcpServers"], dict):
|
|
912
|
+
data["mcpServers"] = {}
|
|
913
|
+
data["mcpServers"]["tokensafe"] = {
|
|
914
|
+
"command": PYTHON_BIN,
|
|
915
|
+
"args": [MCP_SERVER_PATH]
|
|
916
|
+
}
|
|
917
|
+
cls._atomic_write_json(mcp_file, data)
|
|
918
|
+
|
|
919
|
+
managed_plugin_path = info.get("managed_plugin_path")
|
|
920
|
+
if managed_plugin_path:
|
|
921
|
+
cls._symlink_dir(PROJECT_ROOT, managed_plugin_path)
|
|
922
|
+
|
|
923
|
+
installed_json = info.get("installed_json_path")
|
|
924
|
+
if installed_json:
|
|
925
|
+
os.makedirs(os.path.dirname(installed_json), exist_ok=True)
|
|
926
|
+
inst_data, err = cls._load_json_with_backup(installed_json)
|
|
927
|
+
if err or inst_data is None:
|
|
928
|
+
inst_data = {"version": 1, "plugins": []}
|
|
929
|
+
if "plugins" not in inst_data or not isinstance(inst_data["plugins"], list):
|
|
930
|
+
inst_data["plugins"] = []
|
|
931
|
+
|
|
932
|
+
import datetime
|
|
933
|
+
iso_now = datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
934
|
+
plugin_root = managed_plugin_path or PROJECT_ROOT
|
|
935
|
+
|
|
936
|
+
entry_found = False
|
|
937
|
+
for p in inst_data["plugins"]:
|
|
938
|
+
if isinstance(p, dict) and p.get("id") == "tokensafe":
|
|
939
|
+
p["root"] = plugin_root
|
|
940
|
+
p["enabled"] = True
|
|
941
|
+
p["updatedAt"] = iso_now
|
|
942
|
+
p["originalSource"] = PROJECT_ROOT
|
|
943
|
+
p["iconUrl"] = "https://tokensafe.dev/logo.png"
|
|
944
|
+
p["logo"] = "https://tokensafe.dev/logo.png"
|
|
945
|
+
entry_found = True
|
|
946
|
+
break
|
|
947
|
+
if not entry_found:
|
|
948
|
+
inst_data["plugins"].append({
|
|
949
|
+
"id": "tokensafe",
|
|
950
|
+
"root": plugin_root,
|
|
951
|
+
"enabled": True,
|
|
952
|
+
"installedAt": iso_now,
|
|
953
|
+
"updatedAt": iso_now,
|
|
954
|
+
"originalSource": PROJECT_ROOT,
|
|
955
|
+
"origin": "custom",
|
|
956
|
+
"iconUrl": "https://tokensafe.dev/logo.png",
|
|
957
|
+
"logo": "https://tokensafe.dev/logo.png"
|
|
958
|
+
})
|
|
959
|
+
cls._atomic_write_json(installed_json, inst_data)
|
|
960
|
+
|
|
961
|
+
if "skills_path" in info:
|
|
962
|
+
cls._symlink_skill(info["skills_path"])
|
|
963
|
+
|
|
964
|
+
if "agents_md_path" in info:
|
|
965
|
+
cls._inject_global_rule(info["agents_md_path"], UNIFIED_TOKENSAFE_RULE)
|
|
966
|
+
|
|
967
|
+
return True, f"Configured MCP, Plugin, Skill & AGENTS.md for Kimi Code"
|
|
968
|
+
|
|
837
969
|
return False, "Unsupported type"
|
|
838
970
|
|
|
839
971
|
@staticmethod
|
package/src/mcp_server.py
CHANGED
|
@@ -42,7 +42,7 @@ from src.paths import get_active_workspace, is_plugin_or_system_dir
|
|
|
42
42
|
|
|
43
43
|
SERVER_INFO = {
|
|
44
44
|
"name": "tokensafe-mcp",
|
|
45
|
-
"version": "4.1.
|
|
45
|
+
"version": "4.1.8"
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
# MCP client attribution: the initialize handshake carries clientInfo, which
|
|
@@ -54,7 +54,7 @@ _EPOCH_GEN = 0
|
|
|
54
54
|
_IN_PROCESS_DELIVERED = {}
|
|
55
55
|
_KNOWN_POINTER_CLIENTS = (
|
|
56
56
|
"antigravity", "claude", "cursor", "windsurf", "cline", "roo",
|
|
57
|
-
"codex", "zcode", "copilot", "gemini", "zed", "vscode",
|
|
57
|
+
"codex", "zcode", "kimi", "copilot", "gemini", "zed", "vscode",
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
|
|
@@ -180,11 +180,12 @@ TOOLS = [
|
|
|
180
180
|
{
|
|
181
181
|
"name": "sanitize_command",
|
|
182
182
|
"description": "Per-stage shell command rewrites: prunes lockfiles, caps unbounded git log/show/blame/rg "
|
|
183
|
-
"and docker/kubectl logs,
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"
|
|
187
|
-
"
|
|
183
|
+
"and docker/kubectl logs, strips git push progress animations (--no-progress), wraps git commit "
|
|
184
|
+
"with tokensafe wrap when pre-commit/husky hooks exist, and quiets npm/pip installs, bounds cat/curl output. "
|
|
185
|
+
"Compound commands (a && b ; c) are optimized per stage without breaking operators. Test commands "
|
|
186
|
+
"(bun test, pytest, python -m unittest, vitest, jest) are automatically wrapped or forced into run-once mode "
|
|
187
|
+
"(CI=true, --watch=false, --forceExit) so passing suites emit a clean 1-line summary and agents never hang on watch mode. "
|
|
188
|
+
"Pass optional cwd for test commands to unlock package.json runner detection for opaque yarn/npm test scripts.",
|
|
188
189
|
"inputSchema": {
|
|
189
190
|
"type": "object",
|
|
190
191
|
"properties": {
|
package/src/telemetry_sync.py
CHANGED
|
@@ -241,7 +241,7 @@ class TelemetrySync:
|
|
|
241
241
|
current_last_id = last_id
|
|
242
242
|
headers = {
|
|
243
243
|
"Content-Type": "application/json",
|
|
244
|
-
"User-Agent": "TokenSafe-Sync/4.1.
|
|
244
|
+
"User-Agent": "TokenSafe-Sync/4.1.8"
|
|
245
245
|
}
|
|
246
246
|
if active_key:
|
|
247
247
|
headers["Authorization"] = f"Bearer {active_key}"
|
package/src/test_parsers.py
CHANGED
|
@@ -42,6 +42,23 @@ _CARGO_DUR_RE = re.compile(r"finished in\s+(?P<dur>[0-9.]+[a-zA-Z]*)", re.IGNORE
|
|
|
42
42
|
_GO_TEST_OK_RE = re.compile(r"^ok\s+(\S+)\s+([0-9.]+[ms]+)", re.MULTILINE)
|
|
43
43
|
_GO_TEST_FAIL_RE = re.compile(r"^FAIL\s+(\S+)\s+([0-9.]+[ms]+)", re.MULTILINE)
|
|
44
44
|
|
|
45
|
+
# bun test regexes
|
|
46
|
+
_BUN_FILES_SUMMARY_RE = re.compile(
|
|
47
|
+
r"(?P<passed_files>\d+)/(?P<total_files>\d+)\s+test files passed in\s+(?P<dur>[0-9.]+[a-zA-Z]*)",
|
|
48
|
+
re.IGNORECASE
|
|
49
|
+
)
|
|
50
|
+
_BUN_RAN_RE = re.compile(
|
|
51
|
+
r"Ran\s+(?P<tests>\d+)\s+tests?\s+across\s+(?P<files>\d+)\s+files?\.?\s*\[(?P<dur>[0-9.]+[a-zA-Z]*)\]",
|
|
52
|
+
re.IGNORECASE
|
|
53
|
+
)
|
|
54
|
+
_BUN_PASS_RE = re.compile(r"^\s*(?P<pass>\d+)\s+pass\b", re.MULTILINE | re.IGNORECASE)
|
|
55
|
+
_BUN_FAIL_RE = re.compile(r"^\s*(?P<fail>\d+)\s+fail\b", re.MULTILINE | re.IGNORECASE)
|
|
56
|
+
_BUN_EXPECTS_RE = re.compile(r"^\s*(?P<expects>\d+)\s+expect\(\)\s+calls\b", re.MULTILINE | re.IGNORECASE)
|
|
57
|
+
_GIT_COMMIT_CONFIRM_RE = re.compile(
|
|
58
|
+
r"(\[[^\]\r\n]+\s+[0-9a-f]{7,40}\][^\r\n]*(?:\n\s*\d+\s+files?\s+changed[^\r\n]*)?)",
|
|
59
|
+
re.IGNORECASE
|
|
60
|
+
)
|
|
61
|
+
|
|
45
62
|
|
|
46
63
|
class TestOutputParser:
|
|
47
64
|
"""Parses and folds test runner terminal outputs."""
|
|
@@ -49,6 +66,14 @@ class TestOutputParser:
|
|
|
49
66
|
@classmethod
|
|
50
67
|
def detect_runner(cls, cmd_or_output: str) -> Optional[str]:
|
|
51
68
|
s = cmd_or_output.lower()
|
|
69
|
+
if "bun test" in s or "bun:test" in s:
|
|
70
|
+
return "bun test"
|
|
71
|
+
if "expect() calls" in s and ("pass\n" in s or " pass" in s):
|
|
72
|
+
return "bun test"
|
|
73
|
+
if "test files passed in" in s:
|
|
74
|
+
return "bun test"
|
|
75
|
+
if re.search(r"\bran\s+\d+\s+tests?\s+across\s+\d+\s+files?", s):
|
|
76
|
+
return "bun test"
|
|
52
77
|
if "pytest" in s:
|
|
53
78
|
return "pytest"
|
|
54
79
|
if "unittest" in s or ("ran " in s and " tests in " in s):
|
|
@@ -80,7 +105,9 @@ class TestOutputParser:
|
|
|
80
105
|
if not detected:
|
|
81
106
|
return raw, False
|
|
82
107
|
|
|
83
|
-
if detected == "
|
|
108
|
+
if detected == "bun test":
|
|
109
|
+
return cls._compact_bun_test(raw)
|
|
110
|
+
elif detected == "pytest":
|
|
84
111
|
return cls._compact_pytest(raw)
|
|
85
112
|
elif detected == "unittest":
|
|
86
113
|
return cls._compact_unittest(raw)
|
|
@@ -139,6 +166,86 @@ class TestOutputParser:
|
|
|
139
166
|
]
|
|
140
167
|
return "\n".join(res), True
|
|
141
168
|
|
|
169
|
+
@classmethod
|
|
170
|
+
def _compact_bun_test(cls, raw: str) -> Tuple[str, bool]:
|
|
171
|
+
files_m = _BUN_FILES_SUMMARY_RE.search(raw)
|
|
172
|
+
ran_m = _BUN_RAN_RE.search(raw)
|
|
173
|
+
pass_matches = _BUN_PASS_RE.findall(raw)
|
|
174
|
+
fail_matches = _BUN_FAIL_RE.findall(raw)
|
|
175
|
+
expects_matches = _BUN_EXPECTS_RE.findall(raw)
|
|
176
|
+
|
|
177
|
+
if not files_m and not ran_m and not pass_matches:
|
|
178
|
+
return raw, False
|
|
179
|
+
|
|
180
|
+
passed = int(pass_matches[-1]) if pass_matches else 0
|
|
181
|
+
failed = int(fail_matches[-1]) if fail_matches else 0
|
|
182
|
+
|
|
183
|
+
if files_m:
|
|
184
|
+
passed_files = int(files_m.group("passed_files"))
|
|
185
|
+
total_files = int(files_m.group("total_files"))
|
|
186
|
+
dur = files_m.group("dur")
|
|
187
|
+
if passed_files < total_files:
|
|
188
|
+
failed = max(failed, total_files - passed_files)
|
|
189
|
+
else:
|
|
190
|
+
passed_files = total_files = 0
|
|
191
|
+
dur = ran_m.group("dur") if ran_m else ""
|
|
192
|
+
|
|
193
|
+
commit_m = _GIT_COMMIT_CONFIRM_RE.search(raw)
|
|
194
|
+
commit_suffix = f"\n{commit_m.group(1)}" if commit_m else ""
|
|
195
|
+
|
|
196
|
+
if failed == 0:
|
|
197
|
+
if files_m:
|
|
198
|
+
if ran_m:
|
|
199
|
+
tests = ran_m.group("tests")
|
|
200
|
+
exp_str = f", {expects_matches[-1]} expects" if expects_matches else ""
|
|
201
|
+
summary = f"✓ PASS: {passed_files}/{total_files} test files passed ({tests} pass{exp_str} in {dur}) [bun test]{commit_suffix}"
|
|
202
|
+
else:
|
|
203
|
+
summary = f"✓ PASS: {passed_files}/{total_files} test files passed in {dur} [bun test]{commit_suffix}"
|
|
204
|
+
elif ran_m:
|
|
205
|
+
tests = ran_m.group("tests")
|
|
206
|
+
files = ran_m.group("files")
|
|
207
|
+
dur = ran_m.group("dur")
|
|
208
|
+
exp_str = f" ({expects_matches[-1]} expects)" if expects_matches else ""
|
|
209
|
+
summary = f"✓ PASS: {tests} tests passed across {files} file(s) in {dur}{exp_str} [bun test]{commit_suffix}"
|
|
210
|
+
else:
|
|
211
|
+
exp_str = f" ({expects_matches[-1]} expects)" if expects_matches else ""
|
|
212
|
+
summary = f"✓ PASS: {passed} tests passed{exp_str} [bun test]{commit_suffix}"
|
|
213
|
+
return summary, True
|
|
214
|
+
|
|
215
|
+
# Failed run: extract failures and stash full output
|
|
216
|
+
_, marker = stash_block(raw, source="bun_test")
|
|
217
|
+
lines = raw.splitlines()
|
|
218
|
+
failures = []
|
|
219
|
+
cur_fail = []
|
|
220
|
+
in_fail = False
|
|
221
|
+
|
|
222
|
+
for ln in lines:
|
|
223
|
+
s = ln.strip()
|
|
224
|
+
if "✗ " in ln or ln.startswith("error: ") or "Expected:" in ln or "Received:" in ln:
|
|
225
|
+
in_fail = True
|
|
226
|
+
if in_fail:
|
|
227
|
+
cur_fail.append(ln)
|
|
228
|
+
if len(cur_fail) >= 8 or ("✗ " in ln and len(cur_fail) > 1):
|
|
229
|
+
failures.append("\n".join(cur_fail))
|
|
230
|
+
cur_fail = []
|
|
231
|
+
in_fail = False
|
|
232
|
+
if len(failures) >= 5:
|
|
233
|
+
break
|
|
234
|
+
if cur_fail and len(failures) < 5:
|
|
235
|
+
failures.append("\n".join(cur_fail))
|
|
236
|
+
|
|
237
|
+
dur_str = f" in {dur}" if dur else ""
|
|
238
|
+
out = [
|
|
239
|
+
f"✗ FAIL: {failed} failed, {passed} passed{dur_str} [bun test]",
|
|
240
|
+
"Failures excerpt:"
|
|
241
|
+
]
|
|
242
|
+
for fb in failures:
|
|
243
|
+
out.append(f" {fb}")
|
|
244
|
+
out.append(marker)
|
|
245
|
+
if commit_suffix:
|
|
246
|
+
out.append(commit_suffix.strip())
|
|
247
|
+
return "\n".join(out), True
|
|
248
|
+
|
|
142
249
|
@classmethod
|
|
143
250
|
def _compact_unittest(cls, raw: str) -> Tuple[str, bool]:
|
|
144
251
|
lines = raw.splitlines()
|
|
@@ -154,7 +261,8 @@ class TestOutputParser:
|
|
|
154
261
|
return raw, False
|
|
155
262
|
|
|
156
263
|
if status.startswith("OK"):
|
|
157
|
-
|
|
264
|
+
status_clean = f" ({status})" if status else ""
|
|
265
|
+
return f"✓ {ran} — all tests passed{status_clean}", True
|
|
158
266
|
|
|
159
267
|
# Extract failure blocks
|
|
160
268
|
_, marker = stash_block(raw, source="unittest")
|
package/src/version_checker.py
CHANGED
|
@@ -17,7 +17,7 @@ import urllib.request
|
|
|
17
17
|
import urllib.error
|
|
18
18
|
from typing import Dict, Any, Optional, Tuple
|
|
19
19
|
|
|
20
|
-
CURRENT_VERSION = "4.1.
|
|
20
|
+
CURRENT_VERSION = "4.1.8"
|
|
21
21
|
CACHE_TTL = 86400 # 24 hours
|
|
22
22
|
# When the cloud is unreachable we must NOT cache the synthesized "up to date"
|
|
23
23
|
# answer for a full day — otherwise an update released right after an outage
|