tokensafe 2.8.3 → 2.8.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/package.json +1 -1
- package/plugin.json +1 -1
- package/rules/AGENTS.md +4 -4
- package/server.json +3 -3
- package/skills/token-optimizer/SKILL.md +15 -11
- package/src/installer.py +4 -4
- package/src/mcp_server.py +45 -16
- package/src/proxy.py +1 -1
- package/src/telemetry_sync.py +1 -1
- package/src/version_checker.py +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokensafe",
|
|
3
3
|
"mcpName": "dev.tokensafe/tokensafe",
|
|
4
|
-
"version": "2.8.
|
|
4
|
+
"version": "2.8.4",
|
|
5
5
|
"description": "Reduce your AI bills by up to 99% locally. Your agents read only needed code, keep prompt caches intact across turns, and keep secrets out of git.",
|
|
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": "2.8.
|
|
4
|
+
"version": "2.8.4",
|
|
5
5
|
"description": "Reduce your AI bills by up to 99% locally. Your agents read only needed code, keep prompt caches intact across turns, and keep secrets out of git.",
|
|
6
6
|
"logo": "assets/logo.svg",
|
|
7
7
|
"author": {
|
package/rules/AGENTS.md
CHANGED
|
@@ -29,11 +29,11 @@ Execute the specified action directly based on these extracted parameters.
|
|
|
29
29
|
|
|
30
30
|
### 3. Architecture & Code Navigation Directives (Graph-Guided)
|
|
31
31
|
1. **Zero Raw Terminal Grep/Find (Blocked & Replaced by `scoped_search`)**: Strictly NEVER execute terminal `grep`, `egrep`, `ripgrep`, or `find` on source code files or directories (`src/`, `views/`, `components/`, `.ts`, `.tsx`, `.py`, `.js`). These commands are hard-blocked by TokenSafe Guard. To search for text, symbols, or functions across unknown files, ALWAYS call `tokensafe:scoped_search(query, path=".", scope="code")`. The `path` parameter accepts the project root or subfolder (`"."`, `"./src"`), and `scope` accepts file categories (`"code"`, `"config"`, `"all"`), file extensions (`"go"`, `"ts"`), or subfolders (`"internal/promo"`).
|
|
32
|
-
2. **Mandatory Symbol & Component Inspection**: Whenever locating or reading a function, class, component, or method, ALWAYS call `tokensafe:smart_read_file` with `path` and `symbol`. By default (`dep_mode="signature"`), it preserves the full executable target and compact 1-line 1-hop dependency signatures while folding inert code (-95%+ tokens). Pass `dep_mode="full"` only when dependency bodies are needed, or `force_full=true` if a cache pointer references content missing from your context. When you need 3+ related symbols across several files, call `tokensafe:smart_bundle(targets=[{path, symbol}])` ONCE instead of repeated `smart_read_file` calls — it merges the skeletons and deduplicates shared imports/types in a single roundtrip. For OpenAPI/Prisma/GraphQL/SQL schema files `smart_read_file` auto-slices: pass the spec path/model/type/table as `symbol` (empty `symbol` returns a compact overview).
|
|
33
|
-
3. **Architecture Discovery**: Before executing multi-file exploration, ALWAYS call `tokensafe:get_architecture_graph(project_path)` to locate God Nodes and dependency topology in < 250 tokens without file crawling.
|
|
34
|
-
4. **API Surface Map**: Use `tokensafe:get_api_surface(project_path)` to get all exported classes, types, and interfaces in a single markdown map.
|
|
32
|
+
2. **Mandatory Symbol & Component Inspection**: Whenever locating or reading a function, class, component, or method, ALWAYS call `tokensafe:smart_read_file` with `path` (relative e.g. `"src/service.ts"` or absolute) and `symbol`. By default (`dep_mode="signature"`), it preserves the full executable target and compact 1-line 1-hop dependency signatures while folding inert code (-95%+ tokens). Pass `dep_mode="full"` only when dependency bodies are needed, or `force_full=true` if a cache pointer references content missing from your context. When you need 3+ related symbols across several files, call `tokensafe:smart_bundle(targets=[{path, symbol}])` ONCE instead of repeated `smart_read_file` calls — it merges the skeletons and deduplicates shared imports/types in a single roundtrip. For OpenAPI/Prisma/GraphQL/SQL schema files `smart_read_file` auto-slices: pass the spec path/model/type/table as `symbol` (empty `symbol` returns a compact overview).
|
|
33
|
+
3. **Architecture Discovery**: Before executing multi-file exploration, ALWAYS call `tokensafe:get_architecture_graph(project_path=".")` to locate God Nodes and dependency topology in < 250 tokens without file crawling (`project_path` defaults to active workspace).
|
|
34
|
+
4. **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.
|
|
35
35
|
5. **Bounded Reads**: Never call `read_file` without `StartLine`/`EndLine` on files > 100 lines unless inspecting a skeleton.
|
|
36
|
-
6. **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).
|
|
36
|
+
6. **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"`).
|
|
37
37
|
7. **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.
|
|
38
38
|
8. **Context Budget & Smart Compaction**: Before large multi-step tasks, call `tokensafe:context_budget(model=...)` to check window usage (tools/history/prompts breakdown, 50/80/95% thresholds). When it reports `warning` or `critical`, call `tokensafe:compact_conversation(transcript_path=...)` to fold past turns into a State Ledger instead of letting code quality degrade.
|
|
39
39
|
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "dev.tokensafe/tokensafe",
|
|
4
4
|
"title": "TokenSafe",
|
|
5
5
|
"description": "Reduce your AI bills by up to 99% locally: focused code, warm prompt caches & zero secret leaks.",
|
|
6
|
-
"version": "2.8.
|
|
6
|
+
"version": "2.8.4",
|
|
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": "2.8.
|
|
33
|
+
"version": "2.8.4",
|
|
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": "2.8.
|
|
49
|
+
"version": "2.8.4",
|
|
50
50
|
"runtimeHint": "uvx",
|
|
51
51
|
"transport": {
|
|
52
52
|
"type": "stdio"
|
|
@@ -24,7 +24,7 @@ folds multi-turn conversation history, slices verbose tool outputs, and guards a
|
|
|
24
24
|
- **Mandatory Search Tool (`scoped_search`)**: ALWAYS call `tokensafe:scoped_search(query, path=".", scope="code")` to search for text, identifiers, or symbol definitions across unknown files (-90% tokens). The `path` parameter specifies the search directory or project root (e.g. `"."`, `"./src"`). The `scope` parameter filters files (`"code"`, `"config"`, `"all"`), a file extension (`"go"`, `"ts"`), or a subfolder path (`"internal/promo"`).
|
|
25
25
|
|
|
26
26
|
2. **SYMBOL & COMPONENT EXTRACTION (`smart_read_file`)**:
|
|
27
|
-
- When locating or reading any function, component, class, or handler (e.g. `<LuckyWheelTab>`, `areSectorEqual`, `useWallet`), ALWAYS call `tokensafe:smart_read_file` with `path` and `symbol`.
|
|
27
|
+
- When locating or reading any function, component, class, or handler (e.g. `<LuckyWheelTab>`, `areSectorEqual`, `useWallet`), ALWAYS call `tokensafe:smart_read_file` with `path` (supports relative paths, e.g. `"src/service.ts"`) and `symbol`.
|
|
28
28
|
- **1-Hop Dependency Modes (`dep_mode` & `include_deps`)**: By default (`dep_mode="signature"`), `smart_read_file` returns the full target implementation plus compact 1-line 1-hop dependency signatures and collapsed imports (-95%+ tokens). Pass `"dep_mode": "full"` when full 1-hop dependency bodies are required, or `"include_deps": false` for 0-hop surgical isolation.
|
|
29
29
|
- **Cache Pointer Recovery (`force_full`)**: When repeating an unchanged read in the same MCP session, `smart_read_file` may return a compact pointer referencing the prior output. Reuse that earlier output; only pass `"force_full": true` if your context was compacted or you are a fresh subagent lacking prior turns.
|
|
30
30
|
- **Multi-Symbol Bundles (`smart_bundle`)**: When you need 3+ related symbols across several files, call `tokensafe:smart_bundle(targets=[{path, symbol}])` ONCE instead of chained `smart_read_file` calls (max 8 targets). It merges per-file skeletons, deduplicates shared import/type lines into one block, and unifies 1-hop dependency signatures — one roundtrip instead of many.
|
|
@@ -32,31 +32,35 @@ folds multi-turn conversation history, slices verbose tool outputs, and guards a
|
|
|
32
32
|
- **Result**: Preserves the exact target definition while folding surrounding inert code into clean 1-line signatures without docstrings (-85% to -98% tokens).
|
|
33
33
|
|
|
34
34
|
3. **ARCHITECTURE SURVEY BEFORE BROWSING (`get_architecture_graph`)**:
|
|
35
|
-
- Before multi-file exploration or asking where things are located, ALWAYS call `tokensafe:get_architecture_graph(project_path)
|
|
35
|
+
- Before multi-file exploration or asking where things are located, ALWAYS call `tokensafe:get_architecture_graph(project_path=".")` (`project_path` defaults to active workspace).
|
|
36
36
|
- **Result**: Returns top architectural God Nodes, dependency hubs, and centrality rankings in < 250 tokens without file crawling.
|
|
37
37
|
|
|
38
38
|
4. **API SURFACE INSPECTION (`get_api_surface`)**:
|
|
39
|
-
- Call `tokensafe:get_api_surface(project_path)` to get all exported classes, types, interfaces, and function signatures in a single compact markdown map.
|
|
39
|
+
- Call `tokensafe:get_api_surface(project_path=".")` (`project_path` defaults to active workspace) to get all exported classes, types, interfaces, and function signatures in a single compact markdown map.
|
|
40
40
|
|
|
41
|
-
5. **
|
|
41
|
+
5. **DIRECTORY NAVIGATION (`list_dir`)**:
|
|
42
|
+
- NEVER run `ls -la` or `ls -l` in terminal.
|
|
43
|
+
- Call `tokensafe:list_dir(path=".", depth=2)` for clean directory trees without permissions, timestamps, or lockfiles (-90% tokens). Supports relative subfolders (`path="src"`).
|
|
44
|
+
|
|
45
|
+
6. **SURGICAL FILE EDITS (`edit_file`)**:
|
|
42
46
|
- On existing files with >= 40 lines, wholesale rewrites via `write_file` are blocked by **Output Guard**. Always use `edit_file` with precise `Target` and `Replacement` blocks.
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
7. **SECRET LEAK PREVENTION (ZERO HARDCODED FALLBACKS)**:
|
|
45
49
|
- Never provide real private keys, API secrets, or credentials as fallback values in `os.environ.get()` or `process.env`. Real credentials must exist strictly in environment variables.
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
8. **CONTEXT BUDGET BEFORE HEAVY WORK (`context_budget` → `compact_conversation`)**:
|
|
48
52
|
- Before large multi-step tasks, call `tokensafe:context_budget(model=...)` to check the window budget (tools/history/prompts breakdown, 50/80/95% thresholds).
|
|
49
53
|
- When it reports `warning` or `critical`, call `tokensafe:compact_conversation(transcript_path=...)` to fold past turns into a State Ledger before continuing — do not let context exhaustion degrade code quality mid-task.
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
9. **REPEAT READ DEDUPLICATION & CACHE POINTERS**:
|
|
52
56
|
- Never repeatedly re-read the same file or symbol within an active session.
|
|
53
57
|
- When `smart_read_file` returns a pointer hit (`// [TokenSafe: Pointer Hit for ...]`), reuse earlier context; pass `"force_full": true` only if your context was compacted or you are a fresh subagent lacking prior turns.
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
10. **ZERO-FLUFF EGRESS & SURGICAL DIFFS**:
|
|
60
|
+
- Eliminate conversational preambles, courtesy fillers, and trailing sign-offs.
|
|
61
|
+
- Never reprint full unmodified files or lengthy boilerplate; cite line ranges and provide targeted diffs.
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
11. **COMPACT TEST EXECUTION**:
|
|
60
64
|
- Run unit tests with concise flags or via `tokensafe tests [cmd]` so passing test suites emit a single-line summary (`PASS: ...`) rather than flooding `Messages` history with hundreds of verbose log lines. Full traceback is strictly preserved on failure.
|
|
61
65
|
|
|
62
66
|
---
|
package/src/installer.py
CHANGED
|
@@ -46,12 +46,12 @@ UNIFIED_TOKENSAFE_RULE = (
|
|
|
46
46
|
"## TOKENSAFE GRAPH-FIRST OPTIMIZATION PROTOCOL\n"
|
|
47
47
|
"Always use `tokensafe` MCP tools over default raw file reads or high-output terminal executions to prevent context window exhaustion.\n\n"
|
|
48
48
|
"1. **Zero Raw Grep/Find (Blocked & Replaced by `scoped_search`)**: Strictly NEVER execute terminal `grep`, `egrep`, `ripgrep`, or `find` on source code files or directories (`src/`, `views/`, `components/`, `.ts`, `.tsx`, `.py`, `.js`). These commands are hard-blocked by TokenSafe Guard. To search for text, symbols, or functions across unknown files, ALWAYS call `tokensafe:scoped_search(query, path='.', scope='code')`. The `path` parameter accepts the project root or subfolder (`'.'`), and `scope` accepts categories (`'code'`, `'config'`, `'all'`), extensions (`'go'`, `'ts'`), or subfolders (`'internal/promo'`).\n"
|
|
49
|
-
"2. **Mandatory Symbol & Component Inspection**: Whenever locating or reading a function, class, component, or method, ALWAYS call `tokensafe:smart_read_file` with `path` and `symbol`. By default (`dep_mode='signature'`), it preserves the target body and compact 1-line 1-hop dependency signatures (-95%+ tokens); pass `dep_mode='full'` only when dependency bodies are required, or `force_full=true` if a cache pointer references content missing from your context. When you need 3+ related symbols across several files, call `tokensafe:smart_bundle(targets=[{path, symbol}])` ONCE instead of repeated `smart_read_file` calls — it merges the skeletons and deduplicates shared imports/types in a single roundtrip. For OpenAPI/Prisma/GraphQL/SQL schema files `smart_read_file` auto-slices: pass the spec path/model/type/table as `symbol` (empty `symbol` returns a compact overview).\n"
|
|
49
|
+
"2. **Mandatory Symbol & Component Inspection**: Whenever locating or reading a function, class, component, or method, ALWAYS call `tokensafe:smart_read_file` with `path` (relative e.g. `'src/service.ts'` or absolute) and `symbol`. By default (`dep_mode='signature'`), it preserves the target body and compact 1-line 1-hop dependency signatures (-95%+ tokens); pass `dep_mode='full'` only when dependency bodies are required, or `force_full=true` if a cache pointer references content missing from your context. When you need 3+ related symbols across several files, call `tokensafe:smart_bundle(targets=[{path, symbol}])` ONCE instead of repeated `smart_read_file` calls — it merges the skeletons and deduplicates shared imports/types in a single roundtrip. For OpenAPI/Prisma/GraphQL/SQL schema files `smart_read_file` auto-slices: pass the spec path/model/type/table as `symbol` (empty `symbol` returns a compact overview).\n"
|
|
50
50
|
"3. **Repeat Read Deduplication**: Never repeatedly re-read unchanged files or symbols within the same session. Reuse the earlier skeleton or pointer hit (`// [TokenSafe: Pointer Hit ...]`); pass `force_full=true` only if context was compacted or you are a fresh subagent.\n"
|
|
51
51
|
"4. **Zero-Fluff Egress & Surgical Diffs**: Omit conversational filler, courtesy preambles, and sign-offs. Provide concise bullet prose. Never reprint full unmodified files or lengthy boilerplate; link to file line ranges (`file.ts#L10-L25`) and output surgical diffs.\n"
|
|
52
|
-
"5. **Architecture Discovery**: Always call `tokensafe:get_architecture_graph(project_path)` before exploratory multi-file reading. Returns project God Nodes and key dependency hubs in < 250 tokens without file crawling.\n"
|
|
53
|
-
"6. **API Surface Map**: Use `tokensafe:get_api_surface(project_path)` to get all exported classes, types, and interfaces in a single markdown map.\n"
|
|
54
|
-
"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).\n"
|
|
52
|
+
"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"
|
|
53
|
+
"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"
|
|
54
|
+
"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"
|
|
55
55
|
"8. **Command Sanitization & 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`) — compound commands (`a && b ; c`) are rewritten per stage. Run unit tests with concise flags or via the `tokensafe tests [cmd]` CLI (compact passing summary `PASS: ...`, full traceback only on failure) instead of raw verbose test crawls; never leave `vitest`/`jest` 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"
|
|
56
56
|
"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"
|
|
57
57
|
"10. **Context Budget & Smart Compaction**: Before large multi-step tasks, call `tokensafe:context_budget(model=...)` to inspect window usage; when it reports `warning` or `critical`, call `tokensafe:compact_conversation(transcript_path=...)` before continuing.\n"
|
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": "2.8.
|
|
45
|
+
"version": "2.8.4"
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
# MCP client attribution: the initialize handshake carries clientInfo, which
|
|
@@ -80,12 +80,12 @@ def _client_supports_pointers() -> bool:
|
|
|
80
80
|
TOOLS = [
|
|
81
81
|
{
|
|
82
82
|
"name": "smart_read_file",
|
|
83
|
-
"description": "Reads a code file using AST skeletonization and graph-guided slicing to save 90-99% context tokens. OpenAPI
|
|
83
|
+
"description": "Reads a code file using AST skeletonization and graph-guided slicing to save 90-99% context tokens. Automatically preserves target function/class implementation and 1-line 1-hop dependency signatures while folding inert code. Supports relative paths (e.g. 'src/index.ts'). Declarative schemas (OpenAPI, Prisma, GraphQL, SQL) are auto-sliced: pass model/type/table/endpoint as 'symbol' or omit for a compact overview. For 3+ related symbols across files prefer smart_bundle.",
|
|
84
84
|
"inputSchema": {
|
|
85
85
|
"type": "object",
|
|
86
86
|
"properties": {
|
|
87
|
-
"path": {"type": "string", "description": "
|
|
88
|
-
"symbol": {"type": "string", "description": "Optional: targeted function
|
|
87
|
+
"path": {"type": "string", "description": "File path to read (relative to workspace or absolute, e.g. './src/index.ts')"},
|
|
88
|
+
"symbol": {"type": "string", "description": "Optional: targeted function, method, class, component, or schema model/type to extract with 1-hop dependencies while folding surrounding code (omit for whole-file AST skeleton or schema overview)"},
|
|
89
89
|
"include_deps": {"type": "boolean", "description": "Optional: whether to include 1-hop dependencies (default: true). Set false for 0-hop surgical isolation."},
|
|
90
90
|
"dep_mode": {"type": "string", "enum": ["signature", "full"], "description": "Optional: how 1-hop dependencies are returned when include_deps is true. 'signature' (default, -95%+ tokens) returns compact 1-line signatures; 'full' inlines full dependency bodies."},
|
|
91
91
|
"force_full": {"type": "boolean", "description": "Optional: bypass session pointer deduplication and return the full skeleton directly (use only if your context was compacted or you are a fresh subagent lacking earlier reads)."},
|
|
@@ -97,7 +97,7 @@ TOOLS = [
|
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"name": "smart_bundle",
|
|
100
|
-
"description": "Reads 2-8 related symbols across multiple files as ONE merged context bundle: per-file AST skeletons with shared import lines deduplicated and merged 1-hop dependency signatures. Use it instead of 3+ separate smart_read_file calls on related code (one roundtrip, no duplicated imports/types).",
|
|
100
|
+
"description": "Reads 2-8 related symbols across multiple files as ONE merged context bundle: per-file AST skeletons with shared import lines deduplicated and merged 1-hop dependency signatures. Use it instead of 3+ separate smart_read_file calls on related code (one roundtrip, no duplicated imports/types). Supports relative paths (e.g. targets=[{'path': 'src/api.ts', 'symbol': 'handler'}]).",
|
|
101
101
|
"inputSchema": {
|
|
102
102
|
"type": "object",
|
|
103
103
|
"properties": {
|
|
@@ -107,8 +107,8 @@ TOOLS = [
|
|
|
107
107
|
"items": {
|
|
108
108
|
"type": "object",
|
|
109
109
|
"properties": {
|
|
110
|
-
"path": {"type": "string", "description": "
|
|
111
|
-
"symbol": {"type": "string", "description": "Optional symbol to keep unfolded (class
|
|
110
|
+
"path": {"type": "string", "description": "File path to code file (relative to workspace or absolute)"},
|
|
111
|
+
"symbol": {"type": "string", "description": "Optional symbol to keep unfolded (class, function, or component name)"}
|
|
112
112
|
},
|
|
113
113
|
"required": ["path"]
|
|
114
114
|
},
|
|
@@ -123,21 +123,21 @@ TOOLS = [
|
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
"name": "get_architecture_graph",
|
|
126
|
-
"description": "Returns top architectural God Nodes and dependency topology for the target project. Call this BEFORE reading files or searching.",
|
|
126
|
+
"description": "Returns top architectural God Nodes and dependency topology for the target project in < 250 tokens without file crawling. Call this BEFORE reading files or searching.",
|
|
127
127
|
"inputSchema": {
|
|
128
128
|
"type": "object",
|
|
129
129
|
"properties": {
|
|
130
|
-
"project_path": {"type": "string", "description": "
|
|
130
|
+
"project_path": {"type": "string", "description": "Optional root path of the project (defaults to active workspace, or pass '.' or absolute path)"}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
"name": "get_api_surface",
|
|
136
|
-
"description": "Generates and returns a compact markdown map of all exported interfaces, classes, and types in the project.",
|
|
136
|
+
"description": "Generates and returns a compact markdown map of all exported interfaces, classes, and types in the project without crawling files.",
|
|
137
137
|
"inputSchema": {
|
|
138
138
|
"type": "object",
|
|
139
139
|
"properties": {
|
|
140
|
-
"project_path": {"type": "string", "description": "
|
|
140
|
+
"project_path": {"type": "string", "description": "Optional root path of the project (defaults to active workspace, or pass '.' or absolute path)"}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
},
|
|
@@ -228,11 +228,11 @@ TOOLS = [
|
|
|
228
228
|
},
|
|
229
229
|
{
|
|
230
230
|
"name": "list_dir",
|
|
231
|
-
"description": "Returns a clean, token-efficient directory tree up to depth N without permissions, timestamps, or ignored folders (node_modules, .git, dist, .env). Replaces verbose ls -la.",
|
|
231
|
+
"description": "Returns a clean, token-efficient directory tree up to depth N without permissions, timestamps, or ignored folders (node_modules, .git, dist, .env). Replaces verbose ls -la. Pass '.' for project root or a subfolder like 'src'.",
|
|
232
232
|
"inputSchema": {
|
|
233
233
|
"type": "object",
|
|
234
234
|
"properties": {
|
|
235
|
-
"path": {"type": "string", "description": "Path to the directory (relative to
|
|
235
|
+
"path": {"type": "string", "description": "Path to the directory (relative to workspace or absolute, e.g. '.', './src')"},
|
|
236
236
|
"depth": {"type": "integer", "description": "Maximum traversal depth (default: 2, max: 4)"},
|
|
237
237
|
"max_entries": {"type": "integer", "description": "Maximum entries to display before pruning (default: 80)"}
|
|
238
238
|
},
|
|
@@ -742,8 +742,19 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
742
742
|
if start_line is not None:
|
|
743
743
|
start_line = max(1, start_line)
|
|
744
744
|
|
|
745
|
+
active_ws = get_active_workspace()
|
|
746
|
+
if path and not os.path.isabs(path):
|
|
747
|
+
if active_ws and os.path.exists(os.path.join(active_ws, path)):
|
|
748
|
+
path = os.path.abspath(os.path.join(active_ws, path))
|
|
749
|
+
else:
|
|
750
|
+
path = os.path.abspath(path)
|
|
751
|
+
elif path:
|
|
752
|
+
path = os.path.abspath(path)
|
|
753
|
+
|
|
745
754
|
if not path or not os.path.exists(path):
|
|
746
755
|
return {"isError": True, "content": [{"type": "text", "text": f"File not found: {path}"}]}
|
|
756
|
+
if is_plugin_or_system_dir(path):
|
|
757
|
+
return _fallback_error("smart_read_file", f"refusing to read from system root or plugin dir '{path}'")
|
|
747
758
|
try:
|
|
748
759
|
st = os.stat(path)
|
|
749
760
|
if not stat.S_ISREG(st.st_mode):
|
|
@@ -945,11 +956,19 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
945
956
|
inc_deps, _eff_dep_mode = _resolve_dep_mode(args)
|
|
946
957
|
max_tokens = _safe_int(os.environ.get("TOKENSAFE_BUNDLE_MAX_TOKENS"), 6000, lo=1000, hi=50000)
|
|
947
958
|
|
|
959
|
+
active_ws = get_active_workspace()
|
|
948
960
|
by_file: Dict[str, List[str]] = {}
|
|
949
961
|
for t in targets:
|
|
950
962
|
if not isinstance(t, dict) or not str(t.get("path") or "").strip():
|
|
951
963
|
return _fallback_error("smart_bundle", "each target must be {path: str, symbol?: str}")
|
|
952
|
-
|
|
964
|
+
raw_p = str(t["path"]).strip()
|
|
965
|
+
if not os.path.isabs(raw_p) and active_ws and os.path.exists(os.path.join(active_ws, raw_p)):
|
|
966
|
+
target_p = os.path.abspath(os.path.join(active_ws, raw_p))
|
|
967
|
+
else:
|
|
968
|
+
target_p = os.path.abspath(raw_p)
|
|
969
|
+
if is_plugin_or_system_dir(target_p):
|
|
970
|
+
return _fallback_error("smart_bundle", f"refusing to read from system root or plugin dir '{raw_p}'")
|
|
971
|
+
by_file.setdefault(target_p, []).append(str(t.get("symbol") or "").strip())
|
|
953
972
|
|
|
954
973
|
missing = [p for p in by_file if not os.path.isfile(p)]
|
|
955
974
|
if missing:
|
|
@@ -1440,10 +1459,20 @@ def _dispatch_tool_call(name: str, args: dict) -> dict:
|
|
|
1440
1459
|
if not path:
|
|
1441
1460
|
return _fallback_error("list_dir", "missing required 'path' argument")
|
|
1442
1461
|
|
|
1443
|
-
# Resolve path relative to
|
|
1444
|
-
|
|
1462
|
+
# Resolve path relative to active workspace, cwd, or absolute
|
|
1463
|
+
active_ws = get_active_workspace()
|
|
1464
|
+
if not os.path.isabs(path):
|
|
1465
|
+
if active_ws and os.path.isdir(os.path.join(active_ws, path)):
|
|
1466
|
+
abs_path = os.path.abspath(os.path.join(active_ws, path))
|
|
1467
|
+
else:
|
|
1468
|
+
abs_path = os.path.abspath(path)
|
|
1469
|
+
else:
|
|
1470
|
+
abs_path = os.path.abspath(path)
|
|
1471
|
+
|
|
1445
1472
|
if not os.path.isdir(abs_path):
|
|
1446
1473
|
return _fallback_error("list_dir", f"directory not found: {abs_path}")
|
|
1474
|
+
if is_plugin_or_system_dir(abs_path):
|
|
1475
|
+
return _fallback_error("list_dir", f"refusing to inspect system root or plugin dir '{path}'")
|
|
1447
1476
|
system_roots = {"/", "/Users", "/home", "/root", os.path.expanduser("~")}
|
|
1448
1477
|
depth = _safe_int(args.get("depth"), 2, lo=1, hi=4)
|
|
1449
1478
|
if abs_path in system_roots:
|
package/src/proxy.py
CHANGED
|
@@ -30,7 +30,7 @@ from src.governor import ContextGovernor
|
|
|
30
30
|
from src.paths import resolve_data_dir
|
|
31
31
|
|
|
32
32
|
DEFAULT_PORT = 8765
|
|
33
|
-
DEFAULT_HOST = os.environ.get("HOST", os.environ.get("TOKENSAFE_HOST", "
|
|
33
|
+
DEFAULT_HOST = os.environ.get("HOST", os.environ.get("TOKENSAFE_HOST", "127.0.0.1"))
|
|
34
34
|
DEFAULT_UPSTREAM = "https://api.deepseek.com/v1"
|
|
35
35
|
|
|
36
36
|
class EventBroadcaster:
|
package/src/telemetry_sync.py
CHANGED
|
@@ -228,7 +228,7 @@ class TelemetrySync:
|
|
|
228
228
|
current_last_id = last_id
|
|
229
229
|
headers = {
|
|
230
230
|
"Content-Type": "application/json",
|
|
231
|
-
"User-Agent": "TokenSafe-Sync/2.8.
|
|
231
|
+
"User-Agent": "TokenSafe-Sync/2.8.4"
|
|
232
232
|
}
|
|
233
233
|
if active_key:
|
|
234
234
|
headers["Authorization"] = f"Bearer {active_key}"
|
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 = "2.8.
|
|
20
|
+
CURRENT_VERSION = "2.8.4"
|
|
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
|