ctxman 3.0.0
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/.ctxman/custom-profiles.example.json +20 -0
- package/.ctxman/llm-profiles.json +131 -0
- package/.ctxman/logs/ctxman-2026-07-02.log +156 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/0-b3dd1558-f95b-44b9-a154-18e8c330ae7a.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/1-44bff6d4-e552-4010-a769-e09ad822698d.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/10-37260794-5947-4ecb-b4c8-d732f58f40f1.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/11-0d52a883-5518-463c-9b6d-986c3af89dfd.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/12-ae354646-52f2-49c9-90fb-2e6ed8932663.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/13-5d7d5e57-27da-498b-b734-091b9d38da13.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/14-558ce928-810b-4252-a364-fdd1ee6f8a25.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/15-27e3a58f-8b64-43b8-a9f4-e3369446968b.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/16-a110c390-e5c8-4464-b976-bc7f5195fa15.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/17-97513225-53de-4216-b61a-6337bd0cc4ad.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/18-5ba450f0-c527-459c-bf4f-6d79b5e4285f.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/19-600d3a63-5225-49e9-b8b7-30e037b564ab.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/2-48a61b4e-92cf-4342-8376-914c1b99a9f9.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/20-121dd912-5410-410e-84ff-82c7a23604a0.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/3-bc6844ab-7ea3-4bb3-9ee1-538ce5664a9c.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/4-d5e1754f-dbb5-454e-a9be-2a7da8d7bcf9.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/5-4fae93df-0568-4b6f-8acf-8bef4bba6047.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/6-4b1b8b87-068e-49a3-ba2b-d8dae628b252.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/7-63d040fb-d2fa-4c0f-bed0-53411918a7b0.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/8-c5628cf6-264c-420f-aab8-bc96a9083591.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_transactions/9-c94570aa-5e53-4fcb-971f-cecc1d1d5492.txn +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/1.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/10.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/11.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/12.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/13.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/14.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/15.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/16.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/17.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/18.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/19.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/2.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/20.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/21.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/3.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/4.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/5.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/6.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/7.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/8.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/_versions/9.manifest +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/000010010011011101000010de8621405d9d5cb06540dbf02c.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/0000101001011100011000003fb62a4aa8978974075c144f1c.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/000011010000100111001011c6cc824d628f3bb1f4e04cd5d0.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/001000001000011001011100d8f74349ada090b332cd1df669.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/01000001111010001000010045ab44467bb1e7e4d8ae06bd58.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/01000101101110111110011131ef904241a89e1ffb6ddaf8e3.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/010010110000010000011010fbfcc145c6a8a827b28057a07e.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1000011000101010001110003fb4f045c3835982efa1405324.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/100111011101110111101011f4396b410fa06af3b028d204e6.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/100111100111101000001100596b174e00995d6cc2969cc8dc.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1010001100011000110010102ea16b484d887c7c9725feffd6.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/101101100010101111110111c5230944d9b3af7301b6392dda.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1011011100100111111110105892bf41b5a530fedd7cf516f1.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/10111110000010001011110164e8774742bade87b483c10f36.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1100000100010110001110103ffaca40a2a42c85067ebaf9ae.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/110000010001110110101110664bde4c76a78dfc14b05e83b8.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/11001100111000010100110050645c4281b1f35b2022234f7f.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1101111011001100110111017214924a368f5719eab2246619.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1110000111001010001000002150c24dcab653d39d07032e63.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/1110100000000100000011014d20534967a18b5c87721659ff.lance +0 -0
- package/.ctxman/self-knowledge/documents.lance/data/11110101111010000101011135a0114ef2b35dc6f1297a3381.lance +0 -0
- package/.ctxman/wizard-profiles/code-review/.contextignore +41 -0
- package/.ctxman/wizard-profiles/code-review/.contextinclude +30 -0
- package/.ctxman/wizard-profiles/code-review/.methodignore +26 -0
- package/.ctxman/wizard-profiles/code-review/.methodinclude +47 -0
- package/.ctxman/wizard-profiles/code-review/profile.json +26 -0
- package/.ctxman/wizard-profiles/documentation/.contextignore +21 -0
- package/.ctxman/wizard-profiles/documentation/.contextinclude +24 -0
- package/.ctxman/wizard-profiles/documentation/.methodignore +19 -0
- package/.ctxman/wizard-profiles/documentation/.methodinclude +44 -0
- package/.ctxman/wizard-profiles/documentation/profile.json +27 -0
- package/.ctxman/wizard-profiles/full/.contextignore +23 -0
- package/.ctxman/wizard-profiles/full/.contextinclude +38 -0
- package/.ctxman/wizard-profiles/full/.methodignore +5 -0
- package/.ctxman/wizard-profiles/full/.methodinclude +5 -0
- package/.ctxman/wizard-profiles/full/profile.json +28 -0
- package/.ctxman/wizard-profiles/llm-explain/.contextignore +25 -0
- package/.ctxman/wizard-profiles/llm-explain/.contextinclude +33 -0
- package/.ctxman/wizard-profiles/llm-explain/.methodignore +19 -0
- package/.ctxman/wizard-profiles/llm-explain/.methodinclude +48 -0
- package/.ctxman/wizard-profiles/llm-explain/profile.json +27 -0
- package/.ctxman/wizard-profiles/minimal/.contextignore +27 -0
- package/.ctxman/wizard-profiles/minimal/.contextinclude +14 -0
- package/.ctxman/wizard-profiles/minimal/.methodignore +22 -0
- package/.ctxman/wizard-profiles/minimal/.methodinclude +18 -0
- package/.ctxman/wizard-profiles/minimal/profile.json +26 -0
- package/.ctxman/wizard-profiles/security-audit/.contextignore +36 -0
- package/.ctxman/wizard-profiles/security-audit/.contextinclude +37 -0
- package/.ctxman/wizard-profiles/security-audit/.methodignore +29 -0
- package/.ctxman/wizard-profiles/security-audit/.methodinclude +60 -0
- package/.ctxman/wizard-profiles/security-audit/profile.json +34 -0
- package/README.md +1167 -0
- package/bin/cli.js +650 -0
- package/bin/cm-ask.js +95 -0
- package/bin/cm-gitingest.js +134 -0
- package/bin/cm-update.js +175 -0
- package/bin/mcp-server.js +31 -0
- package/ctxman.js +236 -0
- package/examples/README.md +298 -0
- package/examples/custom-llm-profiles.example.json +19 -0
- package/examples/wizard-profiles/code-review/.contextignore +41 -0
- package/examples/wizard-profiles/code-review/.contextinclude +30 -0
- package/examples/wizard-profiles/code-review/.methodignore +26 -0
- package/examples/wizard-profiles/code-review/.methodinclude +47 -0
- package/examples/wizard-profiles/code-review/profile.json +26 -0
- package/examples/wizard-profiles/documentation/.contextignore +21 -0
- package/examples/wizard-profiles/documentation/.contextinclude +24 -0
- package/examples/wizard-profiles/documentation/.methodignore +19 -0
- package/examples/wizard-profiles/documentation/.methodinclude +44 -0
- package/examples/wizard-profiles/documentation/profile.json +27 -0
- package/examples/wizard-profiles/full/.contextignore +23 -0
- package/examples/wizard-profiles/full/.contextinclude +38 -0
- package/examples/wizard-profiles/full/.methodignore +5 -0
- package/examples/wizard-profiles/full/.methodinclude +5 -0
- package/examples/wizard-profiles/full/profile.json +28 -0
- package/examples/wizard-profiles/llm-explain/.contextignore +25 -0
- package/examples/wizard-profiles/llm-explain/.contextinclude +33 -0
- package/examples/wizard-profiles/llm-explain/.methodignore +19 -0
- package/examples/wizard-profiles/llm-explain/.methodinclude +48 -0
- package/examples/wizard-profiles/llm-explain/profile.json +27 -0
- package/examples/wizard-profiles/minimal/.contextignore +27 -0
- package/examples/wizard-profiles/minimal/.contextinclude +14 -0
- package/examples/wizard-profiles/minimal/.methodignore +22 -0
- package/examples/wizard-profiles/minimal/.methodinclude +18 -0
- package/examples/wizard-profiles/minimal/profile.json +26 -0
- package/examples/wizard-profiles/security-audit/.contextignore +36 -0
- package/examples/wizard-profiles/security-audit/.contextinclude +37 -0
- package/examples/wizard-profiles/security-audit/.methodignore +29 -0
- package/examples/wizard-profiles/security-audit/.methodinclude +60 -0
- package/examples/wizard-profiles/security-audit/profile.json +34 -0
- package/index.js +68 -0
- package/lib/agents/pr-failure-agent.js +201 -0
- package/lib/analyzers/go-method-analyzer.js +126 -0
- package/lib/analyzers/method-analyzer.js +457 -0
- package/lib/analyzers/token-calculator.js +577 -0
- package/lib/api/mcp/prompts.js +319 -0
- package/lib/api/mcp/resources.js +269 -0
- package/lib/api/mcp/server.js +339 -0
- package/lib/api/mcp/transports/HttpSseTransport.js +63 -0
- package/lib/api/rest/server.js +405 -0
- package/lib/cache/CacheManager.js +388 -0
- package/lib/core/Analyzer.js +180 -0
- package/lib/core/ContextBuilder.js +325 -0
- package/lib/core/Reporter.js +270 -0
- package/lib/core/Scanner.js +129 -0
- package/lib/formatters/format-registry.js +419 -0
- package/lib/formatters/gitingest-formatter.js +746 -0
- package/lib/formatters/toon-formatter-v1.3.js +731 -0
- package/lib/formatters/toon-formatter.js +291 -0
- package/lib/integrations/git/BlameTracker.js +142 -0
- package/lib/integrations/git/DiffAnalyzer.js +260 -0
- package/lib/integrations/git/GitClient.js +336 -0
- package/lib/parsers/gitignore-parser.js +127 -0
- package/lib/parsers/method-filter-parser.js +50 -0
- package/lib/plugins/ExporterPlugin.js +102 -0
- package/lib/plugins/LanguagePlugin.js +100 -0
- package/lib/plugins/PluginManager.js +302 -0
- package/lib/rag/DataSourcePlugin.js +31 -0
- package/lib/rag/EmbeddingProvider.js +75 -0
- package/lib/rag/Indexer.js +83 -0
- package/lib/rag/VectorStoreFactory.js +24 -0
- package/lib/rag/sources/FileDataSource.js +70 -0
- package/lib/rag/stores/BaseVectorStore.js +43 -0
- package/lib/rag/stores/ChromaDBStore.js +85 -0
- package/lib/rag/stores/LanceDBStore.js +109 -0
- package/lib/rag/stores/PineconeStore.js +74 -0
- package/lib/ui/dashboard.js +109 -0
- package/lib/ui/index.js +15 -0
- package/lib/ui/progress-bar.js +110 -0
- package/lib/ui/select-input.js +51 -0
- package/lib/ui/wizard.js +359 -0
- package/lib/utils/clipboard-utils.js +66 -0
- package/lib/utils/config-utils.js +94 -0
- package/lib/utils/error-handler.js +145 -0
- package/lib/utils/file-utils.js +89 -0
- package/lib/utils/format-converter.js +325 -0
- package/lib/utils/git-utils.js +337 -0
- package/lib/utils/llm-detector.js +409 -0
- package/lib/utils/logger.js +278 -0
- package/lib/utils/token-utils.js +200 -0
- package/lib/utils/tokenizer-adapter.js +454 -0
- package/lib/utils/updater.js +565 -0
- package/lib/watch/FileWatcher.js +208 -0
- package/lib/watch/IncrementalAnalyzer.js +206 -0
- package/package.json +118 -0
package/README.md
ADDED
|
@@ -0,0 +1,1167 @@
|
|
|
1
|
+
# ctxman
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
**AI Development Platform** with plugin architecture, Git integration, REST API, and watch mode. Supporting 14+ programming languages with method-level filtering, automatic LLM optimization, and real-time analysis. Perfect for AI-assisted development workflows.
|
|
5
|
+
|
|
6
|
+
**v3.0.0** - Platform Foundation Release 🚀
|
|
7
|
+
|
|
8
|
+
## ☕ Support This Project
|
|
9
|
+
|
|
10
|
+
If you find this tool helpful, consider buying me a coffee! Your support helps maintain and improve this project.
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.buymeacoffee.com/hakkisagdic" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<img src="docs/qr-code.png" alt="Support QR Code" width="300">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Files
|
|
23
|
+
|
|
24
|
+
- **`ctxman.js`** - Main LLM context analysis script with exact token counting
|
|
25
|
+
- **`.contextignore`** - Files to exclude from token calculation (EXCLUDE mode)
|
|
26
|
+
- **`.contextinclude`** - Files to include in token calculation (INCLUDE mode)
|
|
27
|
+
- **`README.md`** - This documentation file
|
|
28
|
+
- **`README-tr.md`** - Turkish documentation (Türkçe dokümantasyon)
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
### 🚀 Platform Features (v3.0.0)
|
|
33
|
+
- 🔌 **Plugin Architecture** - Modular, extensible system for languages and exporters
|
|
34
|
+
- 🔀 **Git Integration** - Analyze only changed files, diff analysis, author tracking
|
|
35
|
+
- 👁️ **Watch Mode** - Real-time file monitoring and auto-analysis
|
|
36
|
+
- 🌐 **REST API** - HTTP server for programmatic access (6 endpoints)
|
|
37
|
+
- ⚡ **Performance** - Caching system, parallel processing (5-10x faster)
|
|
38
|
+
- 🏗️ **Modular Core** - Scanner, Analyzer, ContextBuilder, Reporter
|
|
39
|
+
|
|
40
|
+
### 🎨 User Interface
|
|
41
|
+
- 🧙 **Interactive Wizard Mode** - User-friendly guided setup (default)
|
|
42
|
+
- 💻 **CLI Mode** - Traditional command-line interface (--cli flag)
|
|
43
|
+
- 📤 **Interactive export** - Prompts for export choice when no options specified
|
|
44
|
+
|
|
45
|
+
### 🔢 Token Analysis
|
|
46
|
+
- ✅ **Exact token counting** using tiktoken (GPT-4 compatible)
|
|
47
|
+
- 🌍 **Multi-language support** - 14+ languages: JavaScript, TypeScript, Python, PHP, Ruby, Java, Kotlin, C#, Go, Rust, Swift, C/C++, Scala
|
|
48
|
+
- 🎯 **Method-level analysis** - Analyze tokens per function/method
|
|
49
|
+
- 📊 **Detailed reporting** - by file type, largest files, statistics
|
|
50
|
+
|
|
51
|
+
### 🎯 Filtering & Configuration
|
|
52
|
+
- 🚫 **Dual ignore system** - respects both `.gitignore` and context ignore rules
|
|
53
|
+
- 📋 **Include/Exclude modes** - `.contextinclude` takes priority over `.contextignore`
|
|
54
|
+
- 🔍 **Method filtering** - `.methodinclude` and `.methodignore` for granular control
|
|
55
|
+
- 🎯 **Core application focus** - configured to analyze only essential code files
|
|
56
|
+
|
|
57
|
+
### 📤 Export Options
|
|
58
|
+
- 🤖 **LLM context export** - generate optimized file lists for LLM consumption
|
|
59
|
+
- 📋 **Clipboard integration** - copy context directly to clipboard
|
|
60
|
+
- 💾 **JSON/YAML/CSV/XML exports** - multiple format options
|
|
61
|
+
- 📄 **GitIngest format** - Single-file digest for LLM consumption (inspired by [GitIngest](https://github.com/coderamp-labs/gitingest))
|
|
62
|
+
- 🎯 **TOON format** - Ultra-compact format (40-50% token reduction)
|
|
63
|
+
- 🔀 **Dual context modes** - compact (default) or detailed format
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
### 🧙 Interactive Wizard Mode (Default)
|
|
68
|
+
```bash
|
|
69
|
+
# Launch interactive wizard (guides you through options)
|
|
70
|
+
ctxman
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The wizard provides a user-friendly interface to:
|
|
74
|
+
- Select your use case (Bug Fix, Feature, Code Review, etc.)
|
|
75
|
+
- Choose target LLM (Claude, GPT-4, Gemini, etc.)
|
|
76
|
+
- Pick output format (TOON, JSON, YAML, etc.)
|
|
77
|
+
|
|
78
|
+
**Note:** Wizard mode uses Ink terminal UI. If you experience visual artifacts, use CLI mode with `--cli` flag.
|
|
79
|
+
|
|
80
|
+
### 💻 CLI Mode
|
|
81
|
+
```bash
|
|
82
|
+
# Use CLI mode instead of wizard
|
|
83
|
+
ctxman --cli
|
|
84
|
+
|
|
85
|
+
# CLI mode with options
|
|
86
|
+
ctxman --cli --save-report
|
|
87
|
+
ctxman --cli --context-clipboard
|
|
88
|
+
ctxman --cli --gitingest
|
|
89
|
+
ctxman --cli --method-level
|
|
90
|
+
|
|
91
|
+
# Any analysis flag automatically enables CLI mode
|
|
92
|
+
ctxman -s # Auto CLI (save report)
|
|
93
|
+
ctxman -m # Auto CLI (method-level)
|
|
94
|
+
ctxman --context-export # Auto CLI (export)
|
|
95
|
+
|
|
96
|
+
# Combine multiple exports
|
|
97
|
+
ctxman --cli -g -s # GitIngest digest + detailed report
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 🤖 LLM Optimization (v2.3.7)
|
|
101
|
+
```bash
|
|
102
|
+
# Auto-detect LLM from environment
|
|
103
|
+
export ANTHROPIC_API_KEY=sk-...
|
|
104
|
+
ctxman # Automatically optimizes for Claude
|
|
105
|
+
|
|
106
|
+
# Explicit model selection
|
|
107
|
+
ctxman --target-model claude-sonnet-4.5
|
|
108
|
+
ctxman --target-model gpt-4o
|
|
109
|
+
ctxman --target-model gemini-2.0-flash
|
|
110
|
+
|
|
111
|
+
# List all supported models
|
|
112
|
+
ctxman --list-llms
|
|
113
|
+
|
|
114
|
+
# Context fit analysis
|
|
115
|
+
ctxman --cli --target-model claude-sonnet-4.5
|
|
116
|
+
# Output:
|
|
117
|
+
# 📊 Context Window Analysis:
|
|
118
|
+
# Target Model: Claude Sonnet 4.5
|
|
119
|
+
# Available Context: 200,000 tokens
|
|
120
|
+
# Your Repository: 181,480 tokens
|
|
121
|
+
# ✅ PERFECT FIT! Your entire codebase fits in one context.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Supported LLM models (9+ models):
|
|
125
|
+
- **Anthropic**: Claude Sonnet 4.5, Claude Opus 4
|
|
126
|
+
- **OpenAI**: GPT-4 Turbo, GPT-4o, GPT-4o Mini
|
|
127
|
+
- **Google**: Gemini 1.5 Pro, Gemini 2.0 Flash
|
|
128
|
+
- **DeepSeek**: DeepSeek Coder, DeepSeek Chat
|
|
129
|
+
|
|
130
|
+
Custom models supported via `.ctxman/custom-profiles.json`
|
|
131
|
+
|
|
132
|
+
### 🔀 Git Integration (v3.0.0)
|
|
133
|
+
```bash
|
|
134
|
+
# Analyze only uncommitted changes
|
|
135
|
+
ctxman --changed-only
|
|
136
|
+
|
|
137
|
+
# Analyze changes since a commit/branch
|
|
138
|
+
ctxman --changed-since main
|
|
139
|
+
ctxman --changed-since HEAD~5
|
|
140
|
+
ctxman --changed-since v2.3.0
|
|
141
|
+
|
|
142
|
+
# With author information
|
|
143
|
+
ctxman --changed-only --with-authors
|
|
144
|
+
|
|
145
|
+
# Output:
|
|
146
|
+
# 🔀 Git Integration - Analyzing Changed Files
|
|
147
|
+
# ══════════════════════════════════════════════════════════
|
|
148
|
+
#
|
|
149
|
+
# 📝 Found 3 changed files
|
|
150
|
+
# Impact: MEDIUM (score: 25)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 👁️ Watch Mode (v3.0.0)
|
|
154
|
+
```bash
|
|
155
|
+
# Start watch mode
|
|
156
|
+
ctxman watch
|
|
157
|
+
|
|
158
|
+
# With method-level analysis
|
|
159
|
+
ctxman watch -m
|
|
160
|
+
|
|
161
|
+
# Custom debounce (default: 1000ms)
|
|
162
|
+
ctxman watch --debounce 2000
|
|
163
|
+
|
|
164
|
+
# Output:
|
|
165
|
+
# 👁️ Watch mode active
|
|
166
|
+
# 📝 File change: src/server.js
|
|
167
|
+
# ✅ Analysis complete: 12,450 tokens (45ms)
|
|
168
|
+
# 📊 Total: 64 files, 181,530 tokens
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 🌐 API Server (v3.0.0)
|
|
172
|
+
```bash
|
|
173
|
+
# Start API server
|
|
174
|
+
ctxman serve
|
|
175
|
+
|
|
176
|
+
# Custom port and authentication
|
|
177
|
+
ctxman serve --port 8080 --auth-token my-secret-token
|
|
178
|
+
|
|
179
|
+
# API Endpoints:
|
|
180
|
+
# GET /api/v1/analyze - Full project analysis
|
|
181
|
+
# GET /api/v1/methods - Extract methods from file
|
|
182
|
+
# GET /api/v1/stats - Project statistics
|
|
183
|
+
# GET /api/v1/diff - Git diff analysis
|
|
184
|
+
# POST /api/v1/context - Smart context generation
|
|
185
|
+
# GET /api/v1/docs - API documentation
|
|
186
|
+
|
|
187
|
+
# Example API calls:
|
|
188
|
+
curl http://localhost:3000/api/v1/analyze
|
|
189
|
+
curl http://localhost:3000/api/v1/methods?file=src/server.js
|
|
190
|
+
curl http://localhost:3000/api/v1/diff?since=main
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Wrapper Script Usage
|
|
194
|
+
```bash
|
|
195
|
+
# Using the NPM package globally
|
|
196
|
+
ctxman
|
|
197
|
+
ctxman --save-report
|
|
198
|
+
ctxman --context-clipboard
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## 🧪 Testing & Validation
|
|
202
|
+
|
|
203
|
+
### Test Repositories
|
|
204
|
+
|
|
205
|
+
Ctxman includes real-world test repositories for validation:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Express.js test repo (git submodule)
|
|
209
|
+
cd test-repos/express
|
|
210
|
+
|
|
211
|
+
# Run full test suite
|
|
212
|
+
ctxman --cli -m --target-model claude-sonnet-4.5
|
|
213
|
+
|
|
214
|
+
# Git integration test
|
|
215
|
+
ctxman --changed-since v5.0.0
|
|
216
|
+
|
|
217
|
+
# Watch mode test
|
|
218
|
+
ctxman watch
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
See [test-repos/README.md](test-repos/README.md) for complete testing guide.
|
|
222
|
+
|
|
223
|
+
### Manual Testing
|
|
224
|
+
|
|
225
|
+
Complete manual testing guide available at [docs/MANUAL-TESTING-v3.0.md](docs/MANUAL-TESTING-v3.0.md)
|
|
226
|
+
|
|
227
|
+
Includes:
|
|
228
|
+
- ✅ 50+ test scenarios for all v3.0.0 features
|
|
229
|
+
- ✅ API endpoint validation
|
|
230
|
+
- ✅ Git integration testing
|
|
231
|
+
- ✅ Watch mode validation
|
|
232
|
+
- ✅ Performance benchmarks
|
|
233
|
+
|
|
234
|
+
### Automated Tests
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Run all tests
|
|
238
|
+
npm run test:comprehensive
|
|
239
|
+
|
|
240
|
+
# Run v3.0.0 specific tests
|
|
241
|
+
npm run test:v3
|
|
242
|
+
npm run test:git
|
|
243
|
+
npm run test:plugin
|
|
244
|
+
npm run test:api
|
|
245
|
+
npm run test:watch
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Current Configuration
|
|
249
|
+
|
|
250
|
+
The tool is configured to focus on **core application logic only**:
|
|
251
|
+
|
|
252
|
+
### ✅ Included (64 JS files, ~181k tokens)
|
|
253
|
+
- Core MCP server implementation (`utility-mcp/src/`)
|
|
254
|
+
- Authentication and security layers
|
|
255
|
+
- Request handlers and routing
|
|
256
|
+
- Transport protocols and communication
|
|
257
|
+
- Utilities and validation logic
|
|
258
|
+
- Configuration management
|
|
259
|
+
- Error handling and monitoring
|
|
260
|
+
|
|
261
|
+
### 🚫 Excluded via context ignore rules
|
|
262
|
+
- Documentation files (`.md`, `.txt`)
|
|
263
|
+
- Configuration files (`.json`, `.yml`)
|
|
264
|
+
- Infrastructure and deployment files
|
|
265
|
+
- Testing and script directories
|
|
266
|
+
- Build artifacts and dependencies
|
|
267
|
+
- Workflow orchestration files (`utility-mcp/src/workflows/**`)
|
|
268
|
+
- Testing utilities (`utility-mcp/src/testing/**`)
|
|
269
|
+
- All non-essential supporting files
|
|
270
|
+
|
|
271
|
+
## Usage
|
|
272
|
+
|
|
273
|
+
### Basic Analysis
|
|
274
|
+
```bash
|
|
275
|
+
# Interactive analysis with export selection
|
|
276
|
+
ctxman
|
|
277
|
+
|
|
278
|
+
# Quiet mode (no file listing)
|
|
279
|
+
ctxman --no-verbose
|
|
280
|
+
|
|
281
|
+
# With detailed JSON report
|
|
282
|
+
ctxman --save-report
|
|
283
|
+
|
|
284
|
+
# Generate LLM context file list
|
|
285
|
+
ctxman --context-export
|
|
286
|
+
|
|
287
|
+
# Copy context directly to clipboard
|
|
288
|
+
ctxman --context-clipboard
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Interactive Export Selection
|
|
292
|
+
|
|
293
|
+
When you run the tool without specifying export options (`--save-report`, `--context-export`, or `--context-clipboard`), it will automatically prompt you to choose an export option after the analysis:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Run analysis and get prompted for export options
|
|
297
|
+
ctxman
|
|
298
|
+
|
|
299
|
+
# The tool will show:
|
|
300
|
+
# 📤 Export Options:
|
|
301
|
+
# 1) Save detailed JSON report (token-analysis-report.json)
|
|
302
|
+
# 2) Generate LLM context file (llm-context.json)
|
|
303
|
+
# 3) Copy LLM context to clipboard
|
|
304
|
+
# 4) No export (skip)
|
|
305
|
+
#
|
|
306
|
+
# 🤔 Which export option would you like? (1-4):
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
This interactive mode ensures you never miss the opportunity to export your analysis results in the format you need.
|
|
310
|
+
|
|
311
|
+
## Include vs Exclude Modes
|
|
312
|
+
|
|
313
|
+
The token calculator supports two complementary filtering modes:
|
|
314
|
+
|
|
315
|
+
### EXCLUDE Mode (.contextignore)
|
|
316
|
+
- **Default mode** when only `.contextignore` exists
|
|
317
|
+
- Includes all files **except** those matching ignore patterns
|
|
318
|
+
- Traditional gitignore-style exclusion logic
|
|
319
|
+
|
|
320
|
+
### INCLUDE Mode (.contextinclude)
|
|
321
|
+
- **Priority mode** - when `.contextinclude` exists, `.contextignore` is ignored
|
|
322
|
+
- Includes **only** files matching include patterns
|
|
323
|
+
- More precise control for specific file selection
|
|
324
|
+
- Perfect for creating focused analysis sets
|
|
325
|
+
|
|
326
|
+
### Mode Priority
|
|
327
|
+
1. If `.contextinclude` exists → **INCLUDE mode** (ignore `.contextignore`)
|
|
328
|
+
2. If only `.contextignore` exists → **EXCLUDE mode**
|
|
329
|
+
3. If neither exists → Include all files (respect `.gitignore` only)
|
|
330
|
+
|
|
331
|
+
### Example Usage
|
|
332
|
+
```bash
|
|
333
|
+
# EXCLUDE mode: Include everything except patterns in .contextignore
|
|
334
|
+
rm .contextinclude # Remove include file
|
|
335
|
+
ctxman
|
|
336
|
+
|
|
337
|
+
# INCLUDE mode: Include only patterns in .contextinclude
|
|
338
|
+
# (automatically ignores .contextignore)
|
|
339
|
+
ctxman
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Help and Options
|
|
343
|
+
```bash
|
|
344
|
+
ctxman --help
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Available Options
|
|
348
|
+
- `--save-report`, `-s` - Save detailed JSON report
|
|
349
|
+
- `--no-verbose` - Disable file listing (verbose is default)
|
|
350
|
+
- `--context-export` - Generate LLM context file list (saves as llm-context.json)
|
|
351
|
+
- `--context-clipboard` - Copy LLM context directly to clipboard
|
|
352
|
+
- `--detailed-context` - Use detailed context format (8.6k chars, default is compact 1.2k)
|
|
353
|
+
- `--help`, `-h` - Show help message
|
|
354
|
+
|
|
355
|
+
## LLM Context Export
|
|
356
|
+
|
|
357
|
+
The token calculator can generate optimized file lists for LLM consumption, with two format options:
|
|
358
|
+
|
|
359
|
+
### Ultra-Compact Format (Default)
|
|
360
|
+
- **Size**: ~2.3k characters (structured JSON)
|
|
361
|
+
- **Content**: Project metadata and organized file paths without token counts
|
|
362
|
+
- **Format**: Identical to llm-context.json file - complete JSON structure
|
|
363
|
+
- **Perfect for**: LLM consumption, programmatic processing, structured data needs
|
|
364
|
+
- **Usage**: `--context-clipboard` or `--context-export`
|
|
365
|
+
|
|
366
|
+
### Detailed Format (Legacy)
|
|
367
|
+
- **Size**: ~8.6k characters (comprehensive)
|
|
368
|
+
- **Content**: Full paths, categories, importance scores, directory stats
|
|
369
|
+
- **Perfect for**: Initial project analysis, comprehensive documentation
|
|
370
|
+
- **Usage**: `--detailed-context --context-clipboard`
|
|
371
|
+
|
|
372
|
+
### Features
|
|
373
|
+
- **Smart file selection** - Top files by token count and importance
|
|
374
|
+
- **Directory grouping** - Common prefix compression saves space
|
|
375
|
+
- **Token abbreviation** - "12k" instead of "12,388 tokens"
|
|
376
|
+
- **Extension removal** - ".js" removed to save characters
|
|
377
|
+
- **Cross-platform clipboard** - Works on macOS, Linux, and Windows
|
|
378
|
+
- **Multiple output formats** - JSON file or clipboard ready text
|
|
379
|
+
|
|
380
|
+
### Usage
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# Generate minimal LLM context and save to llm-context.json (2.3k chars JSON)
|
|
384
|
+
ctxman --context-export
|
|
385
|
+
|
|
386
|
+
# Copy minimal context directly to clipboard (2.3k chars JSON - identical to file)
|
|
387
|
+
ctxman --context-clipboard
|
|
388
|
+
|
|
389
|
+
# Copy detailed context to clipboard (8.6k chars)
|
|
390
|
+
ctxman --detailed-context --context-clipboard
|
|
391
|
+
|
|
392
|
+
# Combine with regular analysis
|
|
393
|
+
ctxman --save-report --context-clipboard
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Output Format Examples
|
|
397
|
+
|
|
398
|
+
**Compact Format (JSON - 2.3k chars):**
|
|
399
|
+
```json
|
|
400
|
+
{
|
|
401
|
+
"project": {
|
|
402
|
+
"root": "cloudstack-go-mcp-proxy",
|
|
403
|
+
"totalFiles": 64,
|
|
404
|
+
"totalTokens": 181480
|
|
405
|
+
},
|
|
406
|
+
"paths": {
|
|
407
|
+
"utility-mcp/src/server/": [
|
|
408
|
+
"CloudStackUtilityMCP.js"
|
|
409
|
+
],
|
|
410
|
+
"utility-mcp/src/handlers/": [
|
|
411
|
+
"workflow-handlers.js",
|
|
412
|
+
"tool-handlers.js",
|
|
413
|
+
"analytics-handler.js"
|
|
414
|
+
],
|
|
415
|
+
"utility-mcp/src/utils/": [
|
|
416
|
+
"security.js",
|
|
417
|
+
"usage-tracker.js",
|
|
418
|
+
"cache-warming.js"
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Detailed Format (8.6k chars):**
|
|
425
|
+
```
|
|
426
|
+
# cloudstack-go-mcp-proxy Codebase Context
|
|
427
|
+
|
|
428
|
+
**Project:** 64 files, 181,480 tokens
|
|
429
|
+
|
|
430
|
+
**Core Files (Top 20):**
|
|
431
|
+
1. `utility-mcp/src/server/CloudStackUtilityMCP.js` (12,388 tokens, server)
|
|
432
|
+
2. `utility-mcp/src/handlers/workflow-handlers.js` (11,007 tokens, handler)
|
|
433
|
+
...
|
|
434
|
+
|
|
435
|
+
**All Files:**
|
|
436
|
+
```json
|
|
437
|
+
[{"path": "file.js", "t": 1234, "c": "core", "i": 85}]
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Use Cases**
|
|
441
|
+
|
|
442
|
+
**Compact Format (2.3k chars JSON):**
|
|
443
|
+
1. **LLM Integration** - Structured data for AI assistants with complete project context
|
|
444
|
+
2. **Programmatic Processing** - JSON format for automated tools and scripts
|
|
445
|
+
3. **Context Sharing** - Identical format in clipboard and file exports
|
|
446
|
+
4. **Development Workflows** - Consistent structure for CI/CD and automation
|
|
447
|
+
|
|
448
|
+
**Detailed Format (8.6k chars):**
|
|
449
|
+
1. **Architecture Planning** - Comprehensive project overview for major decisions
|
|
450
|
+
2. **New Team Member Onboarding** - Complete codebase understanding
|
|
451
|
+
3. **Documentation Generation** - Full project structure analysis
|
|
452
|
+
4. **Code Review Preparation** - Detailed file relationships and importance
|
|
453
|
+
|
|
454
|
+
**General Use Cases:**
|
|
455
|
+
- Development workflow integration
|
|
456
|
+
- CI/CD pipeline context generation
|
|
457
|
+
- Automated documentation updates
|
|
458
|
+
- Project health monitoring
|
|
459
|
+
|
|
460
|
+
## GitIngest Format Export
|
|
461
|
+
|
|
462
|
+
Context-manager now supports generating GitIngest-style digest files - a single, prompt-friendly text file perfect for LLM consumption.
|
|
463
|
+
|
|
464
|
+
### What is GitIngest Format?
|
|
465
|
+
|
|
466
|
+
GitIngest format consolidates your entire codebase into a single text file with:
|
|
467
|
+
- Project summary and statistics
|
|
468
|
+
- Visual directory tree structure
|
|
469
|
+
- Complete file contents with clear separators
|
|
470
|
+
- Token count estimates
|
|
471
|
+
|
|
472
|
+
This format is inspired by [GitIngest](https://github.com/coderamp-labs/gitingest), implemented purely in JavaScript with zero additional dependencies.
|
|
473
|
+
|
|
474
|
+
### Usage
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
# Standard workflow - analyze and generate digest in one step
|
|
478
|
+
ctxman --gitingest
|
|
479
|
+
ctxman -g
|
|
480
|
+
|
|
481
|
+
# Combine with other exports
|
|
482
|
+
ctxman -g -s # digest.txt + token-analysis-report.json
|
|
483
|
+
|
|
484
|
+
# Two-step workflow - generate digest from existing JSON (fast, no re-scan)
|
|
485
|
+
ctxman -s # Step 1: Create report
|
|
486
|
+
ctxman --gitingest-from-report # Step 2: Generate digest
|
|
487
|
+
|
|
488
|
+
# Or from LLM context
|
|
489
|
+
ctxman --context-export # Step 1: Create context
|
|
490
|
+
ctxman --gitingest-from-context # Step 2: Generate digest
|
|
491
|
+
|
|
492
|
+
# With custom filenames
|
|
493
|
+
ctxman --gitingest-from-report my-report.json
|
|
494
|
+
ctxman --gitingest-from-context my-context.json
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
**Why use JSON-based digest?**
|
|
498
|
+
- ⚡ **Performance**: Instant digest generation without re-scanning
|
|
499
|
+
- 🔄 **Reusability**: Generate multiple digests from one analysis
|
|
500
|
+
- 📦 **Workflow**: Separate analysis from export steps
|
|
501
|
+
- 🎯 **Flexibility**: Use different JSON sources for different purposes
|
|
502
|
+
|
|
503
|
+
### Output Example
|
|
504
|
+
|
|
505
|
+
The generated `digest.txt` file looks like:
|
|
506
|
+
|
|
507
|
+
```
|
|
508
|
+
Directory: my-project
|
|
509
|
+
Files analyzed: 42
|
|
510
|
+
|
|
511
|
+
Estimated tokens: 15.2k
|
|
512
|
+
Directory structure:
|
|
513
|
+
└── my-project/
|
|
514
|
+
├── src/
|
|
515
|
+
│ ├── index.js
|
|
516
|
+
│ └── utils.js
|
|
517
|
+
└── README.md
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
================================================
|
|
521
|
+
FILE: src/index.js
|
|
522
|
+
================================================
|
|
523
|
+
[complete file contents here]
|
|
524
|
+
|
|
525
|
+
================================================
|
|
526
|
+
FILE: src/utils.js
|
|
527
|
+
================================================
|
|
528
|
+
[complete file contents here]
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Key Features
|
|
532
|
+
|
|
533
|
+
- **Single File**: Everything in one file for easy LLM ingestion
|
|
534
|
+
- **Tree Visualization**: Clear directory structure
|
|
535
|
+
- **Token Estimates**: Formatted as "1.2k" or "1.5M"
|
|
536
|
+
- **Sorted Output**: Files sorted by token count (largest first)
|
|
537
|
+
- **Filter Compatible**: Respects all `.gitignore` and context ignore rules
|
|
538
|
+
|
|
539
|
+
### Use Cases
|
|
540
|
+
|
|
541
|
+
1. **LLM Context Windows**: Paste entire codebase as single context
|
|
542
|
+
2. **Code Reviews**: Share complete project snapshot
|
|
543
|
+
3. **Documentation**: Single-file project reference
|
|
544
|
+
4. **AI Analysis**: Perfect for ChatGPT, Claude, or other LLMs
|
|
545
|
+
5. **Archival**: Simple project snapshot format
|
|
546
|
+
|
|
547
|
+
### Version Tracking
|
|
548
|
+
|
|
549
|
+
Context-manager implements GitIngest format v0.3.1. See [docs/GITINGEST_VERSION.md](docs/GITINGEST_VERSION.md) for implementation details and version history.
|
|
550
|
+
|
|
551
|
+
## Configuration
|
|
552
|
+
|
|
553
|
+
### .contextignore File (EXCLUDE Mode)
|
|
554
|
+
|
|
555
|
+
The `.contextignore` file is pre-configured for core application analysis:
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
# Current focus: Only core JS files in utility-mcp/src/
|
|
559
|
+
# Excludes:
|
|
560
|
+
**/*.md # All documentation
|
|
561
|
+
**/*.json # All configuration files
|
|
562
|
+
**/*.yml # All YAML files
|
|
563
|
+
infrastructure/** # Infrastructure code
|
|
564
|
+
workflows/** # Workflow definitions
|
|
565
|
+
docs/** # Documentation directory
|
|
566
|
+
token-analysis/** # Analysis tools themselves
|
|
567
|
+
utility-mcp/scripts/** # Utility scripts
|
|
568
|
+
utility-mcp/src/workflows/** # Workflow JS files
|
|
569
|
+
utility-mcp/src/testing/** # Testing utilities
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### .contextinclude File (INCLUDE Mode)
|
|
573
|
+
|
|
574
|
+
The `.contextinclude` file provides precise file selection:
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
# Include only core JavaScript files
|
|
578
|
+
# This should produce exactly 64 files
|
|
579
|
+
|
|
580
|
+
# Include main entry point
|
|
581
|
+
utility-mcp/index.js
|
|
582
|
+
|
|
583
|
+
# Include all src JavaScript files EXCEPT workflows and testing
|
|
584
|
+
utility-mcp/src/**/*.js
|
|
585
|
+
|
|
586
|
+
# Exclude specific subdirectories (using negation)
|
|
587
|
+
!utility-mcp/src/workflows/**
|
|
588
|
+
!utility-mcp/src/testing/**
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
### Creating Custom Configurations
|
|
592
|
+
|
|
593
|
+
**For EXCLUDE mode** (edit `.contextignore`):
|
|
594
|
+
```bash
|
|
595
|
+
# Remove lines to include more file types
|
|
596
|
+
# Add patterns to exclude specific files
|
|
597
|
+
|
|
598
|
+
# Example: Include documentation
|
|
599
|
+
# **/*.md <- comment out or remove this line
|
|
600
|
+
|
|
601
|
+
# Example: Exclude specific large files
|
|
602
|
+
your-large-file.js
|
|
603
|
+
specific-directory/**
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
**For INCLUDE mode** (create `.contextinclude`):
|
|
607
|
+
```bash
|
|
608
|
+
# Include specific files or patterns
|
|
609
|
+
src/**/*.js # All JS files in src
|
|
610
|
+
config/*.json # Config files only
|
|
611
|
+
docs/api/**/*.md # API documentation only
|
|
612
|
+
|
|
613
|
+
# Use negation to exclude from broad patterns
|
|
614
|
+
src/**/*.js
|
|
615
|
+
!src/legacy/** # Exclude legacy code
|
|
616
|
+
!src/**/*.test.js # Exclude test files
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
## Configuration File Priority
|
|
620
|
+
|
|
621
|
+
1. **`.gitignore`** (project root) - Standard git exclusions (always respected)
|
|
622
|
+
2. **`.contextinclude`** (token-analysis/) - INCLUDE mode (highest priority)
|
|
623
|
+
3. **`.contextignore`** (token-analysis/) - EXCLUDE mode (used when no include file)
|
|
624
|
+
4. **`.contextignore`** (project root) - Fallback EXCLUDE mode location
|
|
625
|
+
|
|
626
|
+
## Installation
|
|
627
|
+
|
|
628
|
+
For exact token counting, install tiktoken:
|
|
629
|
+
|
|
630
|
+
```bash
|
|
631
|
+
npm install tiktoken
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
Without tiktoken, the tool uses smart estimation (~95% accuracy).
|
|
635
|
+
|
|
636
|
+
## Output Example
|
|
637
|
+
|
|
638
|
+
```
|
|
639
|
+
🎯 PROJECT TOKEN ANALYSIS REPORT
|
|
640
|
+
================================================================================
|
|
641
|
+
📊 Total files analyzed: 64
|
|
642
|
+
🔢 Total tokens: 181,480
|
|
643
|
+
💾 Total size: 0.78 MB
|
|
644
|
+
📄 Total lines: 28,721
|
|
645
|
+
📈 Average tokens per file: 2,836
|
|
646
|
+
🚫 Files ignored by .gitignore: 11,912
|
|
647
|
+
📋 Files ignored by calculator rules: 198
|
|
648
|
+
|
|
649
|
+
📋 BY FILE TYPE:
|
|
650
|
+
--------------------------------------------------------------------------------
|
|
651
|
+
Extension Files Tokens Size (KB) Lines
|
|
652
|
+
--------------------------------------------------------------------------------
|
|
653
|
+
.js 64 181,480 799.8 28,721
|
|
654
|
+
|
|
655
|
+
🏆 TOP 5 LARGEST FILES BY TOKEN COUNT:
|
|
656
|
+
--------------------------------------------------------------------------------
|
|
657
|
+
1. 12,388 tokens (6.8%) - utility-mcp/src/server/CloudStackUtilityMCP.js
|
|
658
|
+
2. 11,007 tokens (6.1%) - utility-mcp/src/handlers/workflow-handlers.js
|
|
659
|
+
3. 7,814 tokens (4.3%) - utility-mcp/src/utils/security.js
|
|
660
|
+
4. 6,669 tokens (3.7%) - utility-mcp/src/handlers/tool-handlers.js
|
|
661
|
+
5. 5,640 tokens (3.1%) - utility-mcp/src/ci-cd/pipeline-integration.js
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
## Context Management
|
|
665
|
+
|
|
666
|
+
Perfect for LLM context window optimization:
|
|
667
|
+
- **181k tokens** = Core application logic only
|
|
668
|
+
- **Clean analysis** = No noise from docs, configs, or build files
|
|
669
|
+
- **Focused development** = Essential code for AI-assisted development
|
|
670
|
+
- **Context efficiency** = Maximum useful code per token
|
|
671
|
+
- **Dual mode flexibility** = Precise include/exclude control
|
|
672
|
+
- **Ultra-minimal export** = 1k chars (89% reduction) for frequent AI interactions
|
|
673
|
+
- **Detailed export** = 8.6k chars for comprehensive analysis when needed
|
|
674
|
+
|
|
675
|
+
## Integration
|
|
676
|
+
|
|
677
|
+
You can integrate this tool into:
|
|
678
|
+
- CI/CD pipelines for code size monitoring
|
|
679
|
+
- Pre-commit hooks for token budget checks
|
|
680
|
+
- Documentation generation workflows
|
|
681
|
+
- Code quality gates
|
|
682
|
+
- LLM context preparation workflows
|
|
683
|
+
- Development environment setup
|
|
684
|
+
|
|
685
|
+
## Troubleshooting
|
|
686
|
+
|
|
687
|
+
### Include vs Exclude Mode Issues
|
|
688
|
+
- **INCLUDE mode active**: Remove `.contextinclude` to use EXCLUDE mode
|
|
689
|
+
- **Wrong files included**: Check if `.contextinclude` exists (takes priority)
|
|
690
|
+
- **Mode confusion**: Use verbose mode to see which mode is active
|
|
691
|
+
|
|
692
|
+
### Patterns Not Working
|
|
693
|
+
- Ensure no inline comments in ignore/include pattern files
|
|
694
|
+
- Use file patterns (`docs/**`) instead of directory patterns (`docs/`)
|
|
695
|
+
- Test specific patterns with verbose mode
|
|
696
|
+
- Check pattern syntax: `**` for recursive, `*` for single level
|
|
697
|
+
|
|
698
|
+
### Token Count Issues
|
|
699
|
+
- **Too high**: Review included files with verbose mode, add exclusion patterns
|
|
700
|
+
- **Too low**: Check if important files are excluded, review patterns
|
|
701
|
+
- **Inconsistent**: Verify which mode is active (include vs exclude)
|
|
702
|
+
|
|
703
|
+
### Missing Expected Files
|
|
704
|
+
- Check if files are excluded by `.gitignore` (always respected)
|
|
705
|
+
- Verify calculator ignore/include patterns
|
|
706
|
+
- Ensure files are recognized as text files
|
|
707
|
+
- Use verbose mode to see exclusion reasons
|
|
708
|
+
|
|
709
|
+
# Ctxman
|
|
710
|
+
|
|
711
|
+
LLM context manager with method-level filtering and token optimization. The ultimate tool for AI-assisted development.
|
|
712
|
+
|
|
713
|
+
*Created by Hakkı Sağdıç*
|
|
714
|
+
|
|
715
|
+
## 🚀 Features
|
|
716
|
+
|
|
717
|
+
✅ **File-level token analysis** - Analyze entire files and directories
|
|
718
|
+
🔧 **Method-level analysis** - Extract and analyze specific methods from JavaScript/TypeScript/Rust/C#/Go/Java
|
|
719
|
+
📋 **Dual filtering system** - Include/exclude files and methods with pattern matching
|
|
720
|
+
📊 **LLM context optimization** - Generate ultra-compact context for AI assistants
|
|
721
|
+
🎯 **Exact token counting** - Uses tiktoken for GPT-4 compatible counts
|
|
722
|
+
📤 **Multiple export formats** - JSON reports, clipboard, file exports
|
|
723
|
+
📦 **NPM package** - Use programmatically or as global CLI tool
|
|
724
|
+
🔍 **Pattern matching** - Wildcards and regex support for flexible filtering
|
|
725
|
+
⚡ **Performance optimized** - 36% smaller codebase with enhanced functionality
|
|
726
|
+
|
|
727
|
+
## 📦 Installation
|
|
728
|
+
|
|
729
|
+
### Option 1: NPM Package (Recommended)
|
|
730
|
+
```bash
|
|
731
|
+
# Local installation
|
|
732
|
+
npm install ctxman
|
|
733
|
+
|
|
734
|
+
# Global installation
|
|
735
|
+
npm install -g ctxman
|
|
736
|
+
|
|
737
|
+
# Run globally
|
|
738
|
+
ctxman --help
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
### Option 2: Direct Usage
|
|
742
|
+
```bash
|
|
743
|
+
# Clone and use directly
|
|
744
|
+
git clone <repository>
|
|
745
|
+
cd token-analysis
|
|
746
|
+
node token-calculator.js --help
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
## 🎯 Quick Start
|
|
750
|
+
|
|
751
|
+
### Basic Analysis
|
|
752
|
+
```bash
|
|
753
|
+
# Interactive analysis with export selection
|
|
754
|
+
ctxman
|
|
755
|
+
|
|
756
|
+
# File-level analysis with clipboard export
|
|
757
|
+
ctxman --context-clipboard
|
|
758
|
+
|
|
759
|
+
# Method-level analysis
|
|
760
|
+
ctxman --method-level --context-export
|
|
761
|
+
|
|
762
|
+
# Analysis with reports
|
|
763
|
+
ctxman --method-level --save-report --verbose
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### Advanced Usage
|
|
767
|
+
```bash
|
|
768
|
+
# Focus on specific methods only
|
|
769
|
+
echo "calculateTokens\nhandleRequest\n*Validator" > .methodinclude
|
|
770
|
+
ctxman --method-level
|
|
771
|
+
|
|
772
|
+
# Exclude test methods
|
|
773
|
+
echo "*test*\n*debug*\nconsole" > .methodignore
|
|
774
|
+
ctxman --method-level --context-clipboard
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
## Usage
|
|
778
|
+
|
|
779
|
+
### Command Line Interface
|
|
780
|
+
|
|
781
|
+
```bash
|
|
782
|
+
# Basic analysis
|
|
783
|
+
ctxman
|
|
784
|
+
|
|
785
|
+
# Method-level analysis
|
|
786
|
+
ctxman --method-level
|
|
787
|
+
|
|
788
|
+
# Save detailed report
|
|
789
|
+
ctxman --save-report
|
|
790
|
+
|
|
791
|
+
# Copy context to clipboard
|
|
792
|
+
ctxman --context-clipboard
|
|
793
|
+
|
|
794
|
+
# Combine options
|
|
795
|
+
ctxman --method-level --save-report --verbose
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
### Programmatic Usage
|
|
799
|
+
|
|
800
|
+
```javascript
|
|
801
|
+
const { TokenAnalyzer } = require('ctxman');
|
|
802
|
+
|
|
803
|
+
// Basic file-level analysis
|
|
804
|
+
const analyzer = new TokenAnalyzer('./src', {
|
|
805
|
+
methodLevel: false,
|
|
806
|
+
verbose: true
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
// Method-level analysis
|
|
810
|
+
const methodAnalyzer = new TokenAnalyzer('./src', {
|
|
811
|
+
methodLevel: true,
|
|
812
|
+
saveReport: true
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
analyzer.run();
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
## 🔧 Configuration
|
|
819
|
+
|
|
820
|
+
### File-Level Filtering
|
|
821
|
+
|
|
822
|
+
**Priority Order:**
|
|
823
|
+
1. `.gitignore` (project root) - Standard git exclusions (always respected)
|
|
824
|
+
2. `.contextinclude` - INCLUDE mode (highest priority for files)
|
|
825
|
+
3. `.contextignore` - EXCLUDE mode (fallback for files)
|
|
826
|
+
|
|
827
|
+
**`.contextinclude`** - Include only these files:
|
|
828
|
+
```bash
|
|
829
|
+
# Include only core JavaScript files
|
|
830
|
+
utility-mcp/src/**/*.js
|
|
831
|
+
!utility-mcp/src/testing/**
|
|
832
|
+
!utility-mcp/src/workflows/**
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
**`.contextignore`** - Exclude these files:
|
|
836
|
+
```bash
|
|
837
|
+
# Exclude documentation and config
|
|
838
|
+
**/*.md
|
|
839
|
+
**/*.json
|
|
840
|
+
node_modules/**
|
|
841
|
+
test/
|
|
842
|
+
**/*.test.js
|
|
843
|
+
**/*.spec.js
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
### Method-Level Filtering
|
|
847
|
+
|
|
848
|
+
**`.methodinclude`** - Include only these methods:
|
|
849
|
+
```bash
|
|
850
|
+
# Core business logic methods
|
|
851
|
+
calculateTokens
|
|
852
|
+
generateLLMContext
|
|
853
|
+
analyzeFile
|
|
854
|
+
handleRequest
|
|
855
|
+
validateInput
|
|
856
|
+
processData
|
|
857
|
+
|
|
858
|
+
# Pattern matching
|
|
859
|
+
*Handler # All methods ending with 'Handler'
|
|
860
|
+
*Validator # All methods ending with 'Validator'
|
|
861
|
+
*Manager # All methods ending with 'Manager'
|
|
862
|
+
TokenCalculator.* # All methods in TokenCalculator class
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
**`.methodignore`** - Exclude these methods:
|
|
866
|
+
```bash
|
|
867
|
+
# Utility and debug methods
|
|
868
|
+
console
|
|
869
|
+
*test*
|
|
870
|
+
*debug*
|
|
871
|
+
*helper*
|
|
872
|
+
print*
|
|
873
|
+
main
|
|
874
|
+
|
|
875
|
+
# File-specific exclusions
|
|
876
|
+
server.printStatus
|
|
877
|
+
utils.debugLog
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
### Pattern Syntax
|
|
881
|
+
|
|
882
|
+
| Pattern | Description | Example |
|
|
883
|
+
|---------|-------------|----------|
|
|
884
|
+
| `methodName` | Exact match | `calculateTokens` |
|
|
885
|
+
| `*pattern*` | Contains pattern | `*Handler` matches `requestHandler` |
|
|
886
|
+
| `Class.*` | All methods in class | `TokenCalculator.*` |
|
|
887
|
+
| `file.method` | Specific file method | `server.handleRequest` |
|
|
888
|
+
| `!pattern` | Negation (exclude) | `!*test*` |
|
|
889
|
+
|
|
890
|
+
## 📤 Output Formats
|
|
891
|
+
|
|
892
|
+
### 1. File-Level Context (Default)
|
|
893
|
+
**Use case:** General codebase analysis, file organization
|
|
894
|
+
|
|
895
|
+
```json
|
|
896
|
+
{
|
|
897
|
+
"project": {
|
|
898
|
+
"root": "my-project",
|
|
899
|
+
"totalFiles": 64,
|
|
900
|
+
"totalTokens": 181480
|
|
901
|
+
},
|
|
902
|
+
"paths": {
|
|
903
|
+
"src/core/": ["server.js", "handler.js"],
|
|
904
|
+
"src/utils/": ["helper.js", "validator.js"]
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
### 2. Method-Level Context (`--method-level`)
|
|
910
|
+
**Use case:** Focused analysis, debugging specific methods, LLM context optimization
|
|
911
|
+
|
|
912
|
+
```json
|
|
913
|
+
{
|
|
914
|
+
"project": {
|
|
915
|
+
"root": "my-project",
|
|
916
|
+
"totalFiles": 64,
|
|
917
|
+
"totalTokens": 181480
|
|
918
|
+
},
|
|
919
|
+
"methods": {
|
|
920
|
+
"src/server.js": [
|
|
921
|
+
{"name": "handleRequest", "line": 15, "tokens": 234},
|
|
922
|
+
{"name": "validateInput", "line": 45, "tokens": 156}
|
|
923
|
+
],
|
|
924
|
+
"src/utils.js": [
|
|
925
|
+
{"name": "processData", "line": 12, "tokens": 89}
|
|
926
|
+
]
|
|
927
|
+
},
|
|
928
|
+
"methodStats": {
|
|
929
|
+
"totalMethods": 150,
|
|
930
|
+
"includedMethods": 23,
|
|
931
|
+
"totalMethodTokens": 5670
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
### 3. Detailed Report (JSON)
|
|
937
|
+
**Use case:** Comprehensive analysis, CI/CD integration, historical tracking
|
|
938
|
+
|
|
939
|
+
```json
|
|
940
|
+
{
|
|
941
|
+
"metadata": {
|
|
942
|
+
"generatedAt": "2024-01-15T10:30:00.000Z",
|
|
943
|
+
"projectRoot": "/path/to/project",
|
|
944
|
+
"gitignoreRules": ["node_modules/**", "*.log"],
|
|
945
|
+
"calculatorRules": ["src/**/*.js", "!src/test/**"]
|
|
946
|
+
},
|
|
947
|
+
"summary": {
|
|
948
|
+
"totalFiles": 64,
|
|
949
|
+
"totalTokens": 181480,
|
|
950
|
+
"byExtension": {".js": {"count": 64, "tokens": 181480}},
|
|
951
|
+
"largestFiles": [...]
|
|
952
|
+
},
|
|
953
|
+
"files": [...]
|
|
954
|
+
}
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
## CLI Options
|
|
958
|
+
|
|
959
|
+
| Option | Short | Description |
|
|
960
|
+
|--------|-------|-------------|
|
|
961
|
+
| `--save-report` | `-s` | Save detailed JSON report |
|
|
962
|
+
| `--verbose` | `-v` | Show included files and directories |
|
|
963
|
+
| `--context-export` | | Generate LLM context file |
|
|
964
|
+
| `--context-clipboard` | | Copy context to clipboard |
|
|
965
|
+
| `--method-level` | `-m` | Enable method-level analysis |
|
|
966
|
+
| `--help` | `-h` | Show help message |
|
|
967
|
+
|
|
968
|
+
## 📊 Use Cases & Examples
|
|
969
|
+
|
|
970
|
+
### 1. 🤖 LLM Context Optimization
|
|
971
|
+
**Goal:** Generate minimal context for AI assistants
|
|
972
|
+
|
|
973
|
+
```bash
|
|
974
|
+
# Ultra-compact method-level context
|
|
975
|
+
ctxman --method-level --context-clipboard
|
|
976
|
+
|
|
977
|
+
# Focus on core business logic only
|
|
978
|
+
echo "handleRequest\nprocessData\nvalidateInput" > .methodinclude
|
|
979
|
+
ctxman --method-level --context-export
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
**Result:** 89% smaller context compared to full codebase
|
|
983
|
+
|
|
984
|
+
### 2. 📊 Codebase Analysis
|
|
985
|
+
**Goal:** Understand project complexity and structure
|
|
986
|
+
|
|
987
|
+
```bash
|
|
988
|
+
# Analysis with detailed reports
|
|
989
|
+
ctxman --save-report --verbose
|
|
990
|
+
|
|
991
|
+
# Track largest files and methods
|
|
992
|
+
ctxman --method-level --save-report
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
### 3. 🔍 Method-Level Debugging
|
|
996
|
+
**Goal:** Focus on specific problematic methods
|
|
997
|
+
|
|
998
|
+
```bash
|
|
999
|
+
# Debug authentication methods only
|
|
1000
|
+
echo "*auth*\n*login*\n*validate*" > .methodinclude
|
|
1001
|
+
ctxman --method-level --context-clipboard
|
|
1002
|
+
|
|
1003
|
+
# Exclude test and debug methods
|
|
1004
|
+
echo "*test*\n*debug*\nconsole\nlogger" > .methodignore
|
|
1005
|
+
ctxman --method-level
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
### 4. 🚀 CI/CD Integration
|
|
1009
|
+
**Goal:** Monitor codebase growth and complexity
|
|
1010
|
+
|
|
1011
|
+
```bash
|
|
1012
|
+
# Daily token analysis for monitoring
|
|
1013
|
+
ctxman --save-report > reports/analysis-$(date +%Y%m%d).json
|
|
1014
|
+
|
|
1015
|
+
# Check method complexity trends
|
|
1016
|
+
ctxman --method-level --save-report
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
### 5. 📈 Code Quality Gates
|
|
1020
|
+
**Goal:** Ensure code stays within token budgets
|
|
1021
|
+
|
|
1022
|
+
```bash
|
|
1023
|
+
# Check if codebase exceeds LLM context limits
|
|
1024
|
+
TOKENS=$(ctxman --context-export | jq '.project.totalTokens')
|
|
1025
|
+
if [ $TOKENS -gt 100000 ]; then
|
|
1026
|
+
echo "Codebase too large for LLM context!"
|
|
1027
|
+
exit 1
|
|
1028
|
+
fi
|
|
1029
|
+
```
|
|
1030
|
+
|
|
1031
|
+
## 🛠️ CLI Reference
|
|
1032
|
+
|
|
1033
|
+
### Core Options
|
|
1034
|
+
|
|
1035
|
+
| Option | Short | Description | Example |
|
|
1036
|
+
|--------|-------|-------------|----------|
|
|
1037
|
+
| `--save-report` | `-s` | Save detailed JSON report | `ctxman -s` |
|
|
1038
|
+
| `--verbose` | `-v` | Show included files/methods | `ctxman -v` |
|
|
1039
|
+
| `--context-export` | | Generate LLM context file | `ctxman --context-export` |
|
|
1040
|
+
| `--context-clipboard` | | Copy context to clipboard | `ctxman --context-clipboard` |
|
|
1041
|
+
| `--method-level` | `-m` | Enable method-level analysis | `ctxman -m` |
|
|
1042
|
+
| `--help` | `-h` | Show help message | `ctxman -h` |
|
|
1043
|
+
|
|
1044
|
+
### Usage Patterns
|
|
1045
|
+
|
|
1046
|
+
```bash
|
|
1047
|
+
# Quick analysis with interactive export
|
|
1048
|
+
ctxman
|
|
1049
|
+
|
|
1050
|
+
# Method-level analysis with all outputs
|
|
1051
|
+
ctxman --method-level --save-report --context-export --verbose
|
|
1052
|
+
|
|
1053
|
+
# LLM-optimized context generation
|
|
1054
|
+
ctxman --method-level --context-clipboard
|
|
1055
|
+
|
|
1056
|
+
# CI/CD monitoring
|
|
1057
|
+
ctxman --save-report --context-export
|
|
1058
|
+
|
|
1059
|
+
# Development debugging
|
|
1060
|
+
ctxman --method-level --verbose
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
## 💻 Programmatic API
|
|
1064
|
+
|
|
1065
|
+
### Basic Usage
|
|
1066
|
+
|
|
1067
|
+
```javascript
|
|
1068
|
+
const { TokenAnalyzer } = require('ctxman');
|
|
1069
|
+
|
|
1070
|
+
// File-level analysis
|
|
1071
|
+
const analyzer = new TokenAnalyzer('./src', {
|
|
1072
|
+
verbose: true,
|
|
1073
|
+
saveReport: true
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
analyzer.run();
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
### Method-Level Analysis
|
|
1080
|
+
|
|
1081
|
+
```javascript
|
|
1082
|
+
const { TokenAnalyzer, MethodAnalyzer } = require('ctxman');
|
|
1083
|
+
|
|
1084
|
+
// Method-level analysis with custom filtering
|
|
1085
|
+
const analyzer = new TokenAnalyzer('./src', {
|
|
1086
|
+
methodLevel: true,
|
|
1087
|
+
contextExport: true,
|
|
1088
|
+
verbose: false
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
analyzer.run();
|
|
1092
|
+
|
|
1093
|
+
// Extract methods from specific file
|
|
1094
|
+
const methodAnalyzer = new MethodAnalyzer();
|
|
1095
|
+
const methods = methodAnalyzer.extractMethods(fileContent, 'server.js');
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
### Advanced Configuration
|
|
1099
|
+
|
|
1100
|
+
```javascript
|
|
1101
|
+
const analyzer = new TokenAnalyzer('./src', {
|
|
1102
|
+
// Enable method-level analysis
|
|
1103
|
+
methodLevel: true,
|
|
1104
|
+
|
|
1105
|
+
// Output options
|
|
1106
|
+
saveReport: true,
|
|
1107
|
+
contextExport: true,
|
|
1108
|
+
contextToClipboard: true,
|
|
1109
|
+
|
|
1110
|
+
// Verbosity
|
|
1111
|
+
verbose: true,
|
|
1112
|
+
|
|
1113
|
+
// Compact context (for LLM optimization)
|
|
1114
|
+
compactContext: true
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// Access results
|
|
1118
|
+
analyzer.run();
|
|
1119
|
+
console.log('Analysis complete!');
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
### Custom Method Analysis
|
|
1123
|
+
|
|
1124
|
+
```javascript
|
|
1125
|
+
const { MethodAnalyzer, MethodFilterParser } = require('ctxman');
|
|
1126
|
+
|
|
1127
|
+
// Create custom method filter
|
|
1128
|
+
const filter = new MethodFilterParser(
|
|
1129
|
+
'./custom-methods.include',
|
|
1130
|
+
'./custom-methods.ignore'
|
|
1131
|
+
);
|
|
1132
|
+
|
|
1133
|
+
// Analyze specific file
|
|
1134
|
+
const methodAnalyzer = new MethodAnalyzer();
|
|
1135
|
+
const methods = methodAnalyzer.extractMethods(content, filePath);
|
|
1136
|
+
|
|
1137
|
+
// Filter methods
|
|
1138
|
+
const filteredMethods = methods.filter(method =>
|
|
1139
|
+
filter.shouldIncludeMethod(method.name, fileName)
|
|
1140
|
+
);
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
## Requirements
|
|
1144
|
+
|
|
1145
|
+
- **Node.js**: >= 14.0.0
|
|
1146
|
+
- **tiktoken**: ^1.0.0 (optional, for exact token counts)
|
|
1147
|
+
|
|
1148
|
+
## License
|
|
1149
|
+
|
|
1150
|
+
MIT License - see LICENSE file for details
|
|
1151
|
+
|
|
1152
|
+
## Contributing
|
|
1153
|
+
|
|
1154
|
+
1. Fork the repository
|
|
1155
|
+
2. Create your feature branch
|
|
1156
|
+
3. Add tests for new functionality
|
|
1157
|
+
4. Submit a pull request
|
|
1158
|
+
|
|
1159
|
+
## 📞 Support
|
|
1160
|
+
|
|
1161
|
+
- 🐛 [Report Issues](https://github.com/hakkisagdic/ctxman/issues)
|
|
1162
|
+
- 📖 [Documentation](https://github.com/hakkisagdic/ctxman#readme)
|
|
1163
|
+
- 💬 [Discussions](https://github.com/hakkisagdic/ctxman/discussions)
|
|
1164
|
+
|
|
1165
|
+
---
|
|
1166
|
+
|
|
1167
|
+
*Created with ❤️ by Hakkı Sağdıç*
|