AST-based context compression, test log filtering, and token budget guard for DeepSeek Harness: strips redundant syntax, prunes noisy log lines, and enforces a token ceiling so the context window never overflows.
Install
# from npm (prebuilt)
dsh plugin --profile web add @goodandready/dsh-context-lens
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:GooDAnDReaDY/dsh-context-lens
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
⚡ Overview & Semantic Compression Focus
Note on DSH Core vs Plugin Responsibility:
Context budgeting, token counting, tool result pruning (head/middle/tail), and spilling long results to disk (dsh-spill-policy,dsh-compaction-tool-result-pruner,dsh-token-meter) are natively managed by the DSH core (>= 0.1.5).dsh-context-lensfocuses strictly on what the core does not do — semantic compression:
- AST Code Skeletons: Signatures, interfaces, exported types, and doc comments instead of whole function/method bodies across 9+ languages.
- Path-Based Focus: Full code for active editing targets while surrounding workspace files remain skeletonized.
- Test & Build Log Compression: Failures, errors, stack traces, and test summary instead of raw multi-megabyte terminal streams.
graph LR
subgraph AgentInvocation [Agent Tool Invocations]
CodeTool["context_lens_code(filePath / code)"] --> Lens[dsh-context-lens Semantic Engine]
LogTool["context_lens_log(text, auto: true)"] --> Lens
end
subgraph Lens [Semantic Processing]
Lens --> Focus{Path Focus Check}
Focus -->|File in Focus| FullCode[Direct Read: Full Implementation]
Focus -->|Surrounding Files| AST[Direct Read / AST Skeletonizer]
Lens --> LogCompress[Log Condenser: Errors, Stack & Summary]
end
subgraph Output [Optimized Context]
FullCode --> Agent[🤖 AI Agent Context]
AST --> Agent
LogCompress --> Agent
end
style AgentInvocation fill:#1e1e2e,stroke:#89b4fa,stroke-width:2px,color:#cdd6f4
style Lens fill:#181825,stroke:#cba6f7,stroke-width:2px,color:#cdd6f4
style Output fill:#11111b,stroke:#a6e3a1,stroke-width:2px,color:#cdd6f4
✨ Features
1. 🧬 Multi-Language AST Structural Skeletonizer
- Supported Languages: TypeScript, JavaScript, Python, Go, C/C++, Rust, Java, and SQL DDL.
- Structural Preservation: Retains imports, classes, structs, interfaces, exported types, function signatures, and doc comments while discarding inner implementation bodies.
- Multiline Signature Support: Seamlessly accumulates complex multiline generic arguments, return types, and parameter lists up to block delimiters.
- Pure Regex Implementation: Zero heavy native dependencies or binary parser overhead; runs lightning-fast across any platform.
2. 📋 Intelligent Test & Build Log Condenser
- Supported Test Runners & Tools: Jest, Vitest, Pytest,
node --test, Go test, Cargo, Webpack, Vite, TSC, Maven, Gradle. - Targeted Extraction: Identifies and preserves critical error messages, stack traces, assertion differences (
Expected ... Received ...), and failure context windows. - Successful Run Summarization: Automatically collapses passing runs (0 failures) into concise summary lines.
- Auto-Mode Discrimination: Evaluates command context and text signatures to ensure normal non-test outputs are preserved untouched for core pruning.
- 3 Aggressiveness Modes:
raw: Removes noise lines while keeping general execution order.balanced: Preserves failure sections with surrounding context windows (default).aggressive: Extracts strictly error lines and stack frames.
3. 🎯 Path Focus Management
- Designate specific files or folders as active working targets for the current task.
- Files in focus bypass AST skeletonization, returning complete implementation code.
- Focus state is strictly scoped per session (
sessionId).
🛠️ Agent Tools Reference (Consolidated to 2 Tools)
All tools strictly conform to the DeepSeek Harness tool specification by providing output.render returning structured ContentBlock[] arrays ([{ type: 'text', text: ... }]), ensuring 100% session stability.
| Tool Name | Action / Mode | Parameters | Description |
|---|---|---|---|
context_lens_code |
action: "skeleton" (default) |
filePath?, code?, language?, maxDepth?, sessionId? |
Generates a clean structural AST skeleton directly from filePath (reading file without preliminary read_file token waste) or from code. If file is in active session focus, returns full implementation |
context_lens_code |
action: "focus" |
paths: string[], sessionId? |
Sets active focus file paths or patterns for the current session |
context_lens_code |
action: "get_focus" |
sessionId? |
Retrieves active focus paths for the session |
context_lens_code |
action: "clear_focus" |
sessionId? |
Clears focus paths for the session |
context_lens_log |
N/A | text (or log), mode?, maxLines?, auto?, command? |
Compresses test and build output logs, preserving failures, stack traces, and summary. In auto: true, only runs on recognized test/build outputs |
⚙️ Configuration Schema
Configured via the DSH Settings page (plugins.row.config / plugins.item):
| Property | Type | Default | Description |
|---|---|---|---|
compressionMode |
string |
'balanced' |
Log compression aggressiveness (raw, balanced, aggressive) |
astSkeletonMaxDepth |
number |
3 |
Max depth for AST skeleton generation |
autoCompressThreshold |
number |
4000 |
Character threshold for auto-compressing test/build logs when invoking context_lens_log with auto: true (0 to disable) |
📄 License
MIT © GooDAnDReaDY
Links
More in this category
Tencent/WeKnora#dsh-weknora★ 38466
Four read-only tools over a WeKnora knowledge base: list knowledge bases, hybrid passage search, reassemble one document's chunks in order, and WeKnora's own cited RAG or ReAct-agent answer with a resumable session id.
DayuanJiang/next-ai-draw-io#dsh-plugin★ 37249
Draws draw.io diagrams in DeepSeek Harness through the next-ai-drawio MCP server: the link in the reply opens a live preview in the right sidebar, you can edit the diagram by hand, and each AI change is a version you can restore. Node.js 18+; npx downloads the MCP server on first use.
yikart/AiToEarn#dsh-plugin-aitoearn★ 28879
Generate copy, images and short videos, and publish with one click to Douyin, Kuaishou, Xiaohongshu, WeChat Official, Bilibili, Facebook, TikTok and more, covering the full content lifecycle from creation to publishing and monetization.
superdesigndev/treg★ 9925
Tool catalog for agents: search ~2,600 external endpoints (SEO and SERP, backlinks, social, people and company enrichment, ad libraries, scraping) by the task you want done, read each one's parameters and per-call price, then call it with the credential injected server-side. Ships the skill plus an MCP row that stays disabled until TREG_TOKEN is set.
T-Auto/dsh-ops★ 6075
Provides bash, PowerShell 7, and high-performance Rust tools for DSH on Windows to reduce token usage.
Hithink-Tech-Org/Financial-API#hithink-finance★ 4723
Query Hithink Finance data in DeepSeek Harness, view charts in chat, and save refreshable dashboards.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.