tokenprune_wasm_trim
Prunes TypeScript and JavaScript source via AST parsing, extracting public interfaces, signatures, and exports while summarizing implementations to cut LLM context tokens 50%-70% preserving structure.
Instructions
Prunes TypeScript and JavaScript source code using AST parsing to extract public interfaces, type signatures, and exports while collapsing method implementations into concise summaries. Saves 50%-70% of LLM context window tokens without losing structural semantic information. Use when: Feeding large codebase files or libraries into LLM prompts for high-level architecture reasoning or planning. Do not use when: Auditing git diffs for security vulnerabilities or linting container configurations. Alternative: Use agentpr_guard_audit for PR security verification, or dockerlean_wasm_audit for container optimization. Execution: Runs locally in-memory (<10ms), read-only, idempotent, zero network calls, zero telemetry, air-gapped deterministic.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sourceCode": "<sourceCode>"
},
"name": "tokenprune_wasm_trim"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | Source filename with extension for AST dialect resolution (e.g., 'service.ts', 'component.tsx'). Defaults to 'source.ts'. | |
| licenseKey | No | Optional TopAI Sovereign Pro offline license key (or set TOPAI_LICENSE_KEY env variable). | |
| sourceCode | Yes | Raw TypeScript or JavaScript file content to prune and condense. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roiNotice | Yes | Human-readable summary of prompt efficiency gains. | |
| tokensSaved | Yes | Estimated number of LLM prompt tokens saved by AST pruning. | |
| prunedContent | Yes | Condensed TypeScript/JavaScript content preserving signatures and interfaces. | |
| savingsRatioPercent | Yes | Percentage of tokens pruned from original source (0-100). | |
| estimatedCostSavingsUsd | Yes | Estimated USD savings per LLM call at reference prompt rates ($3/1M tokens). |