vscode-ext-ai-context-generator
已归档的 VS Code 上下文生成器,附真实压缩率复盘与当前 Agent 时代的局限分析。
01 / PROJECT OVERVIEW
项目研究解读
已归档的 VS Code 上下文生成器,附真实压缩率复盘与当前 Agent 时代的局限分析。 本仓库以 TypeScript 为主要技术栈,当前快照索引 191 个文件。报告依据README 与目录结构整理,重点呈现项目用途、工程结构和复用方式,不把宣传描述等同于验证结论。
02 / CORE CAPABILITIES
值得关注的能力
- 01
围绕“已归档的 VS Code 上下文生成器,附真实压缩率复盘与当前 Agent 时代的局限分析”提供公开实现或研究资料
- 02
以 TypeScript 为主,保留 191 个可检查仓库文件
- 03
提供原始 GitHub 链接、目录导览和本地研究快照,便于复核与二次开发
03 / ENGINEERING
工程与仓库结构
仓库以 TypeScript 为主要实现语言,研究快照包含 191 个文件、17 个主要顶层入口。已提供 README 作为使用与能力说明。 项目最近更新时间为 2026-09-20,许可标记为 MIT License。
项目文件与实现资料
项目文件与实现资料
项目文件与实现资料
项目文件与实现资料
演示、模型或静态资源
设计文档、研究记录或项目配图
04 / USE CASES
适合用在哪里
- 学习项目设计与实现
- 评估后用于二次开发
- 作为相关领域的研究参考
05 / QUICK START
从仓库开始
以下命令摘自项目 README 或根据仓库地址生成。请先阅读源仓库的安装要求、许可和脚本,再在自己的环境中运行。
git clone https://github.com/suifei/vscode-ext-ai-context-generator.git
cd vscode-ext-ai-context-generator06 / REPOSITORY MAP
目录证据导览
这里列出快照中的前 191 个索引文件中的代表路径,帮助你快速定位源码、文档、测试与资源。
.aicontextignore.eslintrc.json.gitignore.mocharc.yml.nycrc.yml.prettierrc.vscode/launch.json.vscode/tasks.json.vscodeignoreCHANGELOG.mdLICENSEREADME.mdVSCODE_MARKETPLACE.mdassets/logo.pngassets/logo.svgdocs/ADR-GUIDE.mddocs/ARCHITECTURE.mddocs/AST-SEMANTIC-ROADMAP.mddocs/PRD.mddocs/SEMANTIC-OUTLINE-SPEC.mddocs/TECH-DEBT.mddocs/samples/SEMANTIC-EVAL-REPORT.mdpackage-lock.jsonpackage.jsonpackage.nls.jsonpackage.nls.zh-cn.jsonscripts/generateSemanticEvalReport.cjsscripts/php/ast_dump.phpscripts/runSemanticBundleOnly.cjsscripts/runSemanticC4Sample.cjsscripts/runSemanticCppSamples.cjsscripts/runSemanticCsharpSamples.cjsscripts/runSemanticJavaSamples.cjsscripts/runSemanticPolyglotSamples.cjsscripts/runSemanticSamples.cjssrc/commands/configureCommand.tssrc/commands/generateCommand.tssrc/commands/ignoreFileCommand.tssrc/commands/toggleLargeFileDegradationCommand.tssrc/config/constants.tssrc/core/binaryMetadataExtractor.tssrc/core/contextGenerator.tssrc/core/dirTreeGenerator.tssrc/core/fileReader.tssrc/core/fileScanner.tssrc/core/ignoreFilter.tssrc/core/logger.tssrc/core/smartSummarizer.tssrc/core/templateRenderer.tssrc/core/tokenCounter.tssrc/extension.tssrc/outline/astExtractor.tssrc/outline/astSemanticOutlineExtractor.tssrc/outline/bundleFingerprintUtils.tssrc/outline/cppCfgFlow.tssrc/outline/cppSemanticExtractor.tssrc/outline/cppTrivialAccessor.tssrc/outline/csharpOutlineLexerFallback.tssrc/outline/csharpSemanticExtractor.tssrc/outline/formatConstants.tssrc/outline/goSemanticExtractor.tssrc/outline/javaSemanticExtractor.tssrc/outline/outlineExtractor.tssrc/outline/phpSemanticExtractor.tssrc/outline/polyglotSemanticExtractor.tssrc/outline/pythonSemanticExtractor.tssrc/outline/regexFallback.tssrc/outline/registry.tssrc/outline/semanticOutlineValidation.tssrc/outline/subprocessSemanticPaths.tssrc/outline/treeSitterRuntime.tssrc/outline/typescriptSemanticExtractor.tssrc/summary/configAnalyzer.tssrc/summary/csvAnalyzer.tssrc/summary/docAnalyzer.tssrc/summary/excelAnalyzer.tssrc/summary/genericAnalyzer.tssrc/summary/logAnalyzer.tssrc/summary/pdfAnalyzer.tssrc/summary/pptxAnalyzer.tssrc/summary/wordAnalyzer.tssrc/utils/errorUtils.tssrc/utils/fileUtils.tssrc/utils/gitUtils.tssrc/utils/languageMapper.tssrc/utils/languagePatterns.tssrc/utils/textSummarizer.tssrc/utils/zipReader.tstest/helpers/setup.jstest/mocks/vscode.js
07 / SOURCE NOTES
README 原文摘录
保留原始说明便于复核。中文研究结论以当前快照为依据,后续变化请以 GitHub 仓库为准。
AI Context Generator (Advanced)
## 🗃️ This project is archived and no longer maintained
The code works and the test suite passes, but no further development, bug fixes, or releases
are planned. Issues and pull requests will not be answered. Feel free to fork it.
本项目已归档,不再维护。 代码可用、测试通过,但不会再有新功能、缺陷修复或发布,
Issue 与 PR 也不会得到回复。欢迎自行 fork。
See Why this is archived for an honest assessment of what
this tool is still good for in the current LLM landscape, and what a fork should fix first.
English | 简体中文 | Why archived / 为什么归档
Why this is archived / 为什么归档
The premise it was built on has largely expired
This tool was designed for a world where chat models had no file access, context windows were 4K–32K, and pasting dozens of files by hand was painful. Three of those four premises are gone:
- Context is rarely the binding constraint now. 200K is routine, 1M is available.
- Coding agents read files themselves. Claude Code, Cursor, Copilot and friends have
filesystem access and grep. Packaging a repo into one document to paste is a redundant step inside those tools.
- Targeted retrieval usually beats bulk feeding. Dumping hundreds of thousands of tokens of
mostly-irrelevant code measurably degrades answer quality — it is not just a cost question.
- Only "tokens still cost money" survives intact.
There are also now several tools in this niche (repomix, gitingest, files-to-prompt, …), some with their own tree-sitter compression.
What measurably did not work as advertised
The README used to claim "typically 90%+ compression". Measured across the 36 files larger than 50KB in test/samples (4.58M → 1.12M tokens, 75% overall), the real picture is bimodal and unreliable:
| Code shape | Outline size vs. source | Example |
|---|---|---|
| Dense generated parsers | 9–30% | Go parser 1670KB → 9% |
| Ordinary source | 45–75% | llama-context.cpp → 73% |
| Many one-line stub methods | 100–157% (bigger) | Java BaseListener → 150% |
| Data tables with no functions | ~0% | Go lexer 181KB → 140 tokens |
Two problems are visible here. Each outline entry carries loc/io/dep metadata, so files made of tiny methods come out larger than the source. And more seriously, the near-0% rows are not compression — they are near-total omission, presented to the user as a normal-looking outline with no signal that ~99% of the file was dropped. For a context tool that is the worst failure mode: the model then reasons confidently over an incomplete map.
What still has real value
Honestly narrowed, but not zero — roughly in order of defensibility:
- Chat workflows with no tool access — claude.ai / ChatGPT web, or a corporate-approved chat
endpoint that cannot touch your filesystem. One click to package a folder is still a genuine time saver. This is the largest remaining audience.
- Air-gapped / compliance environments. Processing is 100% local and secrets are redacted.
- Hand-curated subsets. Right-click five files and ask "is the design consistent here" —
human selection often beats agent retrieval, with lower communication cost.
- A reproducible artifact. The output can be diffed, committed, attached to a ticket, or fed
to several models for comparison. Agent exploration is not reproducible.
- The semantic outline itself — a function-level behavioural map of a large unfamiliar
codebase is something agents still do poorly. This is the piece with durable value.
What a fork should do first
- Lead with the repo map, not the bulk dump. The map is the differentiated capability; bulk
export is the depreciating one.
- Emit a machine-readable index for agents (symbol → file → line → summary), so the tool
becomes complementary to agentic IDEs instead of competing with them. This is the biggest unexploited opportunity here.
- Add coverage self-checks. "Extracted 0 functions from a 900KB file" must warn loudly rather
than silently emit an empty shell.
- Shrink the language matrix, or label reliability honestly. Each language extractor is a
small compiler, and its failures are silent — it never crashes, it just quietly reports less. Three languages done right beats seven done halfway.
- Lean into privacy and redaction — agent tooling largely does not do this.
Maintenance reality
A full audit before archiving found roughly 50 real defects in ~10K lines, including:
- the packaged VSIX could not activate at all (broken since 1.5.0 —
web-tree-sitterwas
marked as a webpack external while node_modules was excluded from the package, so it only ever worked in the dev host)
- the Go extractor returning 0 functions on a real 100KB file (correct answer: 634)
- every C# method reporting
-> voidbecause the return-type field name was wrong - 819 of 1496 "functions" in a Dart sample being fabricated by a body-scanning bug
- unclosed Markdown code fences swallowing the rest of every document
- template substitution silently rewriting
$TIMESTAMP/$SCOPEinside users' shell scripts
All of these are fixed in the final commit. They are listed here because they illustrate the point above: the surface area of per-language extractors is large relative to the payoff, and the failures are quiet. See CHANGELOG.md for the full list.
中文摘要
为什么归档:这个工具的设计前提(聊天模型没有文件访问能力、上下文 4K–32K、Token 极度紧张) 如今四条坏了三条。上下文不再是主要约束,编码 Agent 会自己读文件,按需检索通常比整包投喂更准。
实测结论:原 README 宣称的"通常压缩 90%+"不成立。对 test/samples 下 36 个大文件实测整体为 75%,且分布极不稳定:稠密 parser 能到 9–30%,普通源码 45–75%,而由大量单行桩方法构成的文件 比源码还大(最高 157%)。更严重的是,无函数的数据型文件产出近乎为空的大纲——那是**信息丢弃 而非压缩**,且用户拿不到任何提示。
仍然成立的价值:无工具权限的聊天场景、隔离/合规环境、人工精选子集、可复现的产物,以及 语义大纲本身——"在读代码之前先知道该读什么",恰好是长上下文和 Agent 都没解决好的部分。
若要 fork,优先做:把仓库地图提到主位而非整包导出;输出给 Agent 用的机器可读索引(这是最大 的未开发机会);补覆盖率告警;收缩语言矩阵或诚实标注可靠性;把隐私脱敏当作正式卖点。
维护现实:归档前的全面审查在约 1 万行代码里找出约 50 个真实缺陷,包括**打包出来的 VSIX 根本无法激活**(自 1.5.0 起,因为本地开发一直正常所以从未被发现)。每个语言提取器本质上是个 小编译器,而它们的错误几乎都是静默的——不崩溃,只是悄悄少给或给错。全部清单见 CHANGELOG.md,均已在最后一次提交中修复。
English
A VSCode extension that generates structured Markdown context from project files for AI assistant interactions.
Right-click any file/folder → Generate to Clipboard/File/Preview
Features
- Smart Filtering:
.aicontextignoresupport (auto-merges.gitignore) - Intelligent Processing:
- Code files: Full content with syntax highlighting
- Large files (>50KB): TS/JS function-level semantic summary (Compiler API), then LSP/symbol outline for other languages (Py/Go/Rust/Java/C++)
- Logs/CSV/Config: Smart summaries
- Office Documents: Text extraction with smart summarization (PDF/Word/Excel/PowerPoint)
- Binary: Metadata extraction
- Flexible Output: Clipboard, file, or preview tab
- Token Counting: Tiktoken (accurate) or simple estimation
- Custom Templates:
.ai_context_templates/*.mdwith variables - Smart Text Summarization: TextRank algorithm for intelligent content compression
Installation
Press Ctrl+Shift+X → Search "AI Context Generator (Advanced)" → InstallQuick Start
Right-click menu:
- Generate AI Context to Clipboard
- Generate AI Context to File
- Generate AI Context to Preview
Command Palette (Ctrl+Shift+P):
AI Context Generator: Generate AI ContextAI Context Generator: Open LogsAI Context Generator: Generate .aicontextignore
Configuration
Create .aicontextignore in project root (same syntax as .gitignore):
node_modules/**
dist/**
*.min.jsKey Settings (aiContext.*):
| Setting | Default | Description |
|---|---|---|
maxFileSize | 51200 | File size threshold for outline mode (bytes) |
maxTokens | 128000 | Token warning threshold (local counting, no AI API) |
enableLargeFileDegradation | true | Enable size-based large file outline/summary mode |
Template Variables
| Variable | Description |
|---|---|
$PROJECT_NAME | Project/folder name |
$DIR_TREE | ASCII directory tree with emoji |
$FILE_CONTENTS | Formatted file contents |
$TOKEN_COUNT | Total token count |
$FILE_COUNT | Number of files |
Technical Highlights
🧠 Intelligent Layered Processing
The extension uses a layered processing architecture that automatically selects the optimal processing strategy based on file type and size:
| File Type | Processing Method | Output |
|---|---|---|
| Any file ≤50KB | Full read | Source code / text + syntax highlighting |
| Large code files (>50KB) | TS/JS: semantic compressed outline (inputs/returns/flow/calls); others: LSP/symbol outline | Behavior-oriented summary or types, signatures, call relations |
| Large log files (>50KB) | Pattern analysis | Log level distribution, error patterns, time range |
| Large data files (>50KB, .csv/.tsv) | Structure inference | Field types, sample data, statistics |
| Large config files (>50KB, JSON/YAML/XML) | Smart summarization | Structure skeleton, sensitive data redaction |
| Large document files (>50KB, .md/.txt) | Content analysis | Section outline, keyword extraction |
| PDF (.pdf) | Text extraction + TextRank summary | Page structure, key sentences |
| Word (.docx) | Text extraction + TextRank summary | Paragraph structure, key points |
| Excel (.xlsx/.xls) | Spreadsheet analysis | Sheet schemas, column types, sample data |
| PowerPoint (.pptx) | Slide text extraction | Slide titles, content summary |
| Binary files | Metadata extraction | Format info, dimensions/duration, etc. |
🏗️ Large-code outline pipeline
For large code files, extraction order depends on language:
TypeScript / JavaScript
- TypeScript Compiler API — function-level semantic summary (inputs, returns, 3–8 flow steps, calls; optional side effects/branches in
detailed) - DocumentSymbol — hierarchical symbol tree if semantic step is insufficient
- SymbolInformation — flat symbols
- Regex — last resort
Other languages (Python, Go, Rust, Java, C/C++, …)
- DocumentSymbol → SymbolInformation → Regex
Benefits:
- TS/JS prioritizes behavior-oriented context over raw symbol dumps when possible
- Other languages still get concise structural outlines via LSP
- Reduces token consumption versus full file content, but the ratio depends heavily on the code.
Measured over the 36 large files in test/samples (4.58M → 1.12M tokens, 75% overall): dense generated parsers compress to 9–30%, ordinary source lands around 45–75%, and files made of many one-line stub methods can come out larger than the source (up to 157%) because each entry carries loc/io/dep metadata. Data-heavy files with no functions (lexer tables) yield an almost empty outline — that is omission, not compression.
📊 Smart Summary Engine
For non-code files, the extension has dedicated analyzers:
- Log Analyzer: Identifies log level distribution (INFO/WARN/ERROR), detects error patterns, extracts key time ranges
- Config Analyzer: Parses JSON/YAML structure, auto-redacts sensitive fields (password/token/secret)
- Doc Analyzer: Extracts Markdown heading hierarchy, keywords, and paragraph summaries
- CSV Analyzer: Infers field types, detects numeric ranges, provides data samples
- PDF Analyzer: Extracts text with page structure, uses TextRank for intelligent summarization
- Word Analyzer: Extracts .docx text with paragraph detection, generates smart summaries
- Excel Analyzer: Analyzes workbook structure, multiple sheets with schema inference
- PowerPoint Analyzer: Extracts slide titles and content, provides presentation summary
TextRank Algorithm:
- Jaccard similarity for sentence ranking (supports UTF-8/Unicode)
- Extracts key sentences based on

