ctxman 3.0.0 → 3.1.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/llm-profiles.json +1067 -39
- package/.ctxman/profiles/backend-team.json +13 -0
- package/.ctxman/profiles/default.json +12 -0
- package/.ctxman/profiles/devops-team.json +21 -0
- package/.ctxman/profiles/frontend-team.json +20 -0
- package/.ctxman/templates/bug-fix.json +17 -0
- package/.ctxman/templates/code-review.json +9 -0
- package/.ctxman/templates/documentation.json +9 -0
- package/.ctxman/templates/feature.json +9 -0
- package/.ctxman/templates/full-context.json +9 -0
- package/.ctxman/templates/refactoring.json +18 -0
- package/.ctxman/templates/testing.json +9 -0
- package/.ctxman/wizard-profiles/security-audit/profile.json +7 -1
- package/LICENSE +21 -0
- package/README.md +380 -136
- package/bin/cli.js +1880 -529
- package/bin/cm-ask.js +18 -13
- package/bin/cm-audit.js +124 -0
- package/bin/cm-count.js +151 -0
- package/bin/cm-gitingest.js +128 -115
- package/bin/cm-map.js +242 -0
- package/bin/cm-mcp.js +293 -0
- package/bin/cm-pack.js +405 -0
- package/bin/cm-policy.js +170 -0
- package/bin/cm-pr.js +248 -0
- package/bin/cm-search.js +178 -0
- package/bin/cm-update.js +128 -128
- package/bin/cm-why.js +197 -0
- package/bin/mcp-server.js +8 -24
- package/ctxman.js +237 -183
- package/examples/README.md +19 -4
- package/examples/github-actions/ctxman-check.yml +49 -0
- package/examples/wizard-profiles/security-audit/profile.json +7 -1
- package/index.d.ts +1422 -0
- package/index.js +55 -31
- package/lib/agents/pr-failure-agent.js +48 -45
- package/lib/analyzers/ai-suggester.js +451 -0
- package/lib/analyzers/dependency-scanner.js +505 -0
- package/lib/analyzers/duplicate-detector.js +264 -0
- package/lib/analyzers/go-method-analyzer.js +151 -110
- package/lib/analyzers/import-tracker.js +431 -0
- package/lib/analyzers/method-analyzer.js +1055 -434
- package/lib/analyzers/performance-dashboard.js +683 -0
- package/lib/analyzers/token-calculator.js +895 -504
- package/lib/analyzers/unused-exports-detector.js +336 -0
- package/lib/api/mcp/install.js +424 -0
- package/lib/api/mcp/prompts.js +281 -281
- package/lib/api/mcp/resources.js +300 -241
- package/lib/api/mcp/sandbox.js +89 -0
- package/lib/api/mcp/server.js +675 -312
- package/lib/api/mcp/start.js +125 -0
- package/lib/api/mcp/transports/HttpSseTransport.js +60 -52
- package/lib/api/rest/server.js +105 -28
- package/lib/cache/CacheManager.js +9 -17
- package/lib/core/Analyzer.js +16 -10
- package/lib/core/ContextBuilder.js +19 -28
- package/lib/core/Reporter.js +15 -14
- package/lib/core/Scanner.js +81 -12
- package/lib/count/index.js +100 -0
- package/lib/formatters/format-registry.js +394 -372
- package/lib/formatters/gitingest-formatter.js +656 -621
- package/lib/formatters/toon-formatter-v1.3.js +637 -632
- package/lib/formatters/toon-formatter.js +239 -240
- package/lib/integrations/git/BlameTracker.js +4 -4
- package/lib/integrations/git/DiffAnalyzer.js +38 -31
- package/lib/integrations/git/GitClient.js +71 -53
- package/lib/lsp/server.js +311 -0
- package/lib/map/graph.js +299 -0
- package/lib/map/imports.js +233 -0
- package/lib/map/index.js +33 -0
- package/lib/map/rank.js +253 -0
- package/lib/map/render.js +346 -0
- package/lib/map/resolver.js +574 -0
- package/lib/pack/budget.js +111 -0
- package/lib/pack/code-lexer.js +360 -0
- package/lib/pack/compress.js +414 -0
- package/lib/pack/index.js +354 -0
- package/lib/pack/renderers/common.js +134 -0
- package/lib/pack/renderers/index.js +24 -0
- package/lib/pack/renderers/json.js +47 -0
- package/lib/pack/renderers/markdown.js +54 -0
- package/lib/pack/renderers/plain.js +38 -0
- package/lib/pack/renderers/xml.js +85 -0
- package/lib/pack/select.js +177 -0
- package/lib/pack/split.js +182 -0
- package/lib/pack/tree.js +35 -0
- package/lib/parsers/gitignore-parser.js +113 -107
- package/lib/parsers/method-filter-parser.js +50 -33
- package/lib/plugins/ExporterPlugin.js +3 -3
- package/lib/plugins/LanguagePlugin.js +3 -3
- package/lib/plugins/PluginManager.js +7 -13
- package/lib/policy/audit.js +294 -0
- package/lib/policy/enforce.js +125 -0
- package/lib/policy/ignore-files.js +169 -0
- package/lib/policy/index.js +52 -0
- package/lib/policy/policy.js +489 -0
- package/lib/pr/diff-parser.js +267 -0
- package/lib/pr/method-mapper.js +148 -0
- package/lib/pr/pr-context.js +829 -0
- package/lib/pr/pr-git.js +149 -0
- package/lib/pr/pr-renderer.js +644 -0
- package/lib/pr/related-tests.js +296 -0
- package/lib/rag/DataSourcePlugin.js +5 -5
- package/lib/rag/EmbeddingProvider.js +19 -8
- package/lib/rag/Indexer.js +14 -5
- package/lib/rag/VectorStoreFactory.js +3 -3
- package/lib/rag/sources/FileDataSource.js +6 -6
- package/lib/rag/stores/BaseVectorStore.js +5 -5
- package/lib/rag/stores/ChromaDBStore.js +10 -10
- package/lib/rag/stores/LanceDBStore.js +29 -19
- package/lib/rag/stores/PineconeStore.js +11 -9
- package/lib/search/bm25.js +433 -0
- package/lib/search/code-units.js +201 -0
- package/lib/search/symbols.js +189 -0
- package/lib/ui/dashboard.js +120 -89
- package/lib/ui/index.js +1 -6
- package/lib/ui/init-wizard-ui.js +550 -0
- package/lib/ui/progress-bar.js +94 -88
- package/lib/ui/select-input.js +40 -32
- package/lib/ui/template-selector.js +99 -0
- package/lib/ui/wizard.js +374 -329
- package/lib/utils/claude-token-counter.js +151 -0
- package/lib/utils/cli-output.js +17 -0
- package/lib/utils/clipboard-utils.js +49 -50
- package/lib/utils/config-utils.js +81 -66
- package/lib/utils/context-versioning.js +532 -0
- package/lib/utils/error-handler.js +112 -112
- package/lib/utils/file-utils.js +153 -69
- package/lib/utils/format-converter.js +356 -283
- package/lib/utils/git-utils.js +366 -294
- package/lib/utils/llm-cost-estimator.js +281 -0
- package/lib/utils/llm-detector.js +242 -78
- package/lib/utils/logger.js +243 -237
- package/lib/utils/messages.js +355 -0
- package/lib/utils/multi-repo-manager.js +364 -0
- package/lib/utils/profile-manager.js +380 -0
- package/lib/utils/safe-read.js +61 -0
- package/lib/utils/secret-redactor.js +61 -0
- package/lib/utils/snapshot-manager.js +679 -0
- package/lib/utils/template-manager.js +378 -0
- package/lib/utils/token-utils.js +201 -170
- package/lib/utils/tokenizer-adapter.js +421 -377
- package/lib/utils/updater.js +539 -506
- package/lib/watch/FileWatcher.js +12 -8
- package/lib/watch/IncrementalAnalyzer.js +7 -7
- package/lib/why/coupling.js +81 -0
- package/lib/why/errors.js +23 -0
- package/lib/why/git.js +169 -0
- package/lib/why/history.js +108 -0
- package/lib/why/index.js +720 -0
- package/lib/why/ownership.js +79 -0
- package/lib/why/paths.js +207 -0
- package/lib/why/references.js +259 -0
- package/lib/why/render.js +722 -0
- package/lib/why/search.js +358 -0
- package/lib/why/target.js +389 -0
- package/lib/wizards/config-generator.js +255 -0
- package/lib/wizards/project-detector.js +571 -0
- package/package.json +44 -10
- package/.ctxman/logs/ctxman-2026-07-02.log +0 -156
- 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/README.md
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
# ctxman
|
|
2
2
|
|
|
3
|
+
[](https://github.com/hakkisagdic/ctxman/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/hakkisagdic/ctxman/actions/workflows/codeql.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/ctxman)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](docs/)
|
|
3
9
|
|
|
4
10
|
**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
11
|
|
|
6
12
|
**v3.0.0** - Platform Foundation Release 🚀
|
|
7
13
|
|
|
14
|
+
**Languages**: [English](README.md) | [Türkçe](README-tr.md)
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
|
|
18
|
+
- [Support This Project](#-support-this-project)
|
|
19
|
+
- [Features](#features)
|
|
20
|
+
- [Quick Start](#quick-start)
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Usage](#usage)
|
|
23
|
+
- [Configuration](#configuration)
|
|
24
|
+
- [API Server](#api-server)
|
|
25
|
+
- [Git Integration](#-git-integration-v300)
|
|
26
|
+
- [Watch Mode](#-watch-mode-v300)
|
|
27
|
+
- [LLM Optimization](#-llm-optimization-v237)
|
|
28
|
+
- [Export Options](#-export-options)
|
|
29
|
+
- [Documentation](#documentation)
|
|
30
|
+
- [Contributing](#contributing)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
|
|
8
33
|
## ☕ Support This Project
|
|
9
34
|
|
|
10
35
|
If you find this tool helpful, consider buying me a coffee! Your support helps maintain and improve this project.
|
|
@@ -19,9 +44,25 @@ If you find this tool helpful, consider buying me a coffee! Your support helps m
|
|
|
19
44
|
|
|
20
45
|
---
|
|
21
46
|
|
|
47
|
+
## Documentation
|
|
48
|
+
|
|
49
|
+
| Document | Description |
|
|
50
|
+
| -------------------------------------------------- | ------------------------------------------------------- |
|
|
51
|
+
| [API Documentation](docs/API.md) | REST API endpoints and usage |
|
|
52
|
+
| [Architecture](docs/ARCHITECTURE.md) | Plugin system, core modules, data flow |
|
|
53
|
+
| [Performance Benchmarks](docs/PERFORMANCE.md) | Performance metrics and optimization tips |
|
|
54
|
+
| [Changelog](CHANGELOG.md) | Version history and release notes |
|
|
55
|
+
| [Contributing](CONTRIBUTING.md) | Development setup and guidelines |
|
|
56
|
+
| [Security Policy](SECURITY.md) | Security policy and vulnerability reporting |
|
|
57
|
+
| [Code of Conduct](CODE_OF_CONDUCT.md) | Community guidelines |
|
|
58
|
+
| [API Dokümantasyonu](docs/API-tr.md) | REST API dokümantasyonu (Türkçe) |
|
|
59
|
+
| [Mimari](docs/ARCHITECTURE-tr.md) | Plugin sistemi, çekirdek modüller (Türkçe) |
|
|
60
|
+
| [Performans Kıyaslamaları](docs/PERFORMANCE-tr.md) | Performans metrikleri ve optimizasyon ipuçları (Türkçe) |
|
|
61
|
+
| [Katkı Rehberi](CONTRIBUTING-tr.md) | Geliştirme kurulumu ve yönergeler (Türkçe) |
|
|
62
|
+
|
|
22
63
|
## Files
|
|
23
64
|
|
|
24
|
-
- **`ctxman.js`** - Main LLM context analysis script with
|
|
65
|
+
- **`ctxman.js`** - Main LLM context analysis script with token counting
|
|
25
66
|
- **`.contextignore`** - Files to exclude from token calculation (EXCLUDE mode)
|
|
26
67
|
- **`.contextinclude`** - Files to include in token calculation (INCLUDE mode)
|
|
27
68
|
- **`README.md`** - This documentation file
|
|
@@ -30,31 +71,49 @@ If you find this tool helpful, consider buying me a coffee! Your support helps m
|
|
|
30
71
|
## Features
|
|
31
72
|
|
|
32
73
|
### 🚀 Platform Features (v3.0.0)
|
|
74
|
+
|
|
33
75
|
- 🔌 **Plugin Architecture** - Modular, extensible system for languages and exporters
|
|
34
76
|
- 🔀 **Git Integration** - Analyze only changed files, diff analysis, author tracking
|
|
35
77
|
- 👁️ **Watch Mode** - Real-time file monitoring and auto-analysis
|
|
36
78
|
- 🌐 **REST API** - HTTP server for programmatic access (6 endpoints)
|
|
37
|
-
- ⚡ **Performance** -
|
|
79
|
+
- ⚡ **Performance** - Scans ~2,000 files in under 100 ms and counts 2.6M tokens in about 6 s with tiktoken; watch mode re-analyzes only changed files
|
|
38
80
|
- 🏗️ **Modular Core** - Scanner, Analyzer, ContextBuilder, Reporter
|
|
39
81
|
|
|
82
|
+
### 🧰 Context Commands
|
|
83
|
+
|
|
84
|
+
- 📦 **`ctxman pack`** - File contents in one LLM-ready document (Claude XML, Markdown, JSON) with signatures-only compression and a hard token budget
|
|
85
|
+
- 🗺️ **`ctxman map`** - Ranked repository map (import graph + git history) within a token budget
|
|
86
|
+
- 🔍 **`ctxman pr`** - Review context for a branch: log, changed methods, diff, related tests
|
|
87
|
+
- 🧭 **`ctxman why`** - Why code looks as it does: commits, linked issues and PRs, owners, co-changed files, ADRs and tests from local git history
|
|
88
|
+
- 🔎 **`ctxman search`** - Ranked (BM25) search over functions and code chunks
|
|
89
|
+
- 🔢 **`ctxman count`** - Token count for one model, exact for Claude through Anthropic's API
|
|
90
|
+
- 🔌 **`ctxman mcp`** - MCP server with one-command setup for Claude Desktop, Claude Code, Cursor, VS Code and Windsurf
|
|
91
|
+
- 🛡️ **`ctxman policy` / `ctxman audit`** - Export policy (deny rules, required redaction, token limits) and an audit log
|
|
92
|
+
- 🤖 **GitHub Action and Docker image** - Token budgets and model fit as a CI check
|
|
93
|
+
|
|
40
94
|
### 🎨 User Interface
|
|
95
|
+
|
|
41
96
|
- 🧙 **Interactive Wizard Mode** - User-friendly guided setup (default)
|
|
42
97
|
- 💻 **CLI Mode** - Traditional command-line interface (--cli flag)
|
|
43
98
|
- 📤 **Interactive export** - Prompts for export choice when no options specified
|
|
44
99
|
|
|
45
100
|
### 🔢 Token Analysis
|
|
46
|
-
|
|
101
|
+
|
|
102
|
+
- ✅ **Token counting with tiktoken** using the target model's encoding (o200k_base or cl100k_base): exact for OpenAI models up to GPT-5.x, approximate for GPT-6 and other vendors; exact Claude counts with `ctxman count --api`
|
|
47
103
|
- 🌍 **Multi-language support** - 14+ languages: JavaScript, TypeScript, Python, PHP, Ruby, Java, Kotlin, C#, Go, Rust, Swift, C/C++, Scala
|
|
48
104
|
- 🎯 **Method-level analysis** - Analyze tokens per function/method
|
|
49
105
|
- 📊 **Detailed reporting** - by file type, largest files, statistics
|
|
50
106
|
|
|
51
107
|
### 🎯 Filtering & Configuration
|
|
108
|
+
|
|
52
109
|
- 🚫 **Dual ignore system** - respects both `.gitignore` and context ignore rules
|
|
110
|
+
- 🤝 **Other AI tools' ignore files** - `.cursorignore`, `.aiexclude`, `.aiderignore` and others on request (`--respect-ignore-files`)
|
|
53
111
|
- 📋 **Include/Exclude modes** - `.contextinclude` takes priority over `.contextignore`
|
|
54
112
|
- 🔍 **Method filtering** - `.methodinclude` and `.methodignore` for granular control
|
|
55
113
|
- 🎯 **Core application focus** - configured to analyze only essential code files
|
|
56
114
|
|
|
57
115
|
### 📤 Export Options
|
|
116
|
+
|
|
58
117
|
- 🤖 **LLM context export** - generate optimized file lists for LLM consumption
|
|
59
118
|
- 📋 **Clipboard integration** - copy context directly to clipboard
|
|
60
119
|
- 💾 **JSON/YAML/CSV/XML exports** - multiple format options
|
|
@@ -65,19 +124,22 @@ If you find this tool helpful, consider buying me a coffee! Your support helps m
|
|
|
65
124
|
## Quick Start
|
|
66
125
|
|
|
67
126
|
### 🧙 Interactive Wizard Mode (Default)
|
|
127
|
+
|
|
68
128
|
```bash
|
|
69
129
|
# Launch interactive wizard (guides you through options)
|
|
70
130
|
ctxman
|
|
71
131
|
```
|
|
72
132
|
|
|
73
133
|
The wizard provides a user-friendly interface to:
|
|
134
|
+
|
|
74
135
|
- Select your use case (Bug Fix, Feature, Code Review, etc.)
|
|
75
|
-
- Choose target LLM (Claude, GPT
|
|
136
|
+
- Choose target LLM (Claude, GPT, Gemini, etc.)
|
|
76
137
|
- Pick output format (TOON, JSON, YAML, etc.)
|
|
77
138
|
|
|
78
139
|
**Note:** Wizard mode uses Ink terminal UI. If you experience visual artifacts, use CLI mode with `--cli` flag.
|
|
79
140
|
|
|
80
141
|
### 💻 CLI Mode
|
|
142
|
+
|
|
81
143
|
```bash
|
|
82
144
|
# Use CLI mode instead of wizard
|
|
83
145
|
ctxman --cli
|
|
@@ -98,38 +160,209 @@ ctxman --cli -g -s # GitIngest digest + detailed report
|
|
|
98
160
|
```
|
|
99
161
|
|
|
100
162
|
### 🤖 LLM Optimization (v2.3.7)
|
|
163
|
+
|
|
101
164
|
```bash
|
|
102
165
|
# Auto-detect LLM from environment
|
|
103
166
|
export ANTHROPIC_API_KEY=sk-...
|
|
104
167
|
ctxman # Automatically optimizes for Claude
|
|
105
168
|
|
|
106
169
|
# Explicit model selection
|
|
107
|
-
ctxman --target-model claude-sonnet-
|
|
108
|
-
ctxman --target-model gpt-
|
|
109
|
-
ctxman --target-model gemini-
|
|
170
|
+
ctxman --target-model claude-sonnet-5-5
|
|
171
|
+
ctxman --target-model gpt-6.1-sol
|
|
172
|
+
ctxman --target-model gemini-3.8-flash
|
|
110
173
|
|
|
111
174
|
# List all supported models
|
|
112
175
|
ctxman --list-llms
|
|
113
176
|
|
|
114
177
|
# Context fit analysis
|
|
115
|
-
ctxman --cli --target-model claude-sonnet-
|
|
178
|
+
ctxman --cli --target-model claude-sonnet-5-5
|
|
116
179
|
# Output:
|
|
117
180
|
# 📊 Context Window Analysis:
|
|
118
|
-
# Target Model: Claude Sonnet
|
|
119
|
-
# Available Context:
|
|
181
|
+
# Target Model: Claude Sonnet 5.5
|
|
182
|
+
# Available Context: 1,000,000 tokens
|
|
120
183
|
# Your Repository: 181,480 tokens
|
|
121
184
|
# ✅ PERFECT FIT! Your entire codebase fits in one context.
|
|
122
185
|
```
|
|
123
186
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
-
|
|
187
|
+
Some of the supported models (run `ctxman --list-llms` for the full list, checked 2026-10-09):
|
|
188
|
+
|
|
189
|
+
| Vendor | Model ID | Context | Output | $ in/out per 1M tokens |
|
|
190
|
+
| --------- | ------------------------ | ------- | ------ | ---------------------- |
|
|
191
|
+
| Anthropic | `claude-fable-5-1` | 1M | 128K | $10 / $50 |
|
|
192
|
+
| Anthropic | `claude-opus-5-5` | 1M | 128K | $4 / $20 |
|
|
193
|
+
| Anthropic | `claude-sonnet-5-5` | 1M | 128K | $2 / $10 |
|
|
194
|
+
| Anthropic | `claude-haiku-5-5` | 1M | 128K | $0.10 / $0.50 |
|
|
195
|
+
| OpenAI | `gpt-6-astra` | 1.05M | 128K | $10 / $50 |
|
|
196
|
+
| OpenAI | `gpt-6.1-sol` | 1.05M | 128K | $2 / $10 |
|
|
197
|
+
| OpenAI | `gpt-6-luna` | 1.05M | 128K | $0.10 / $0.50 |
|
|
198
|
+
| OpenAI | `gpt-5.5` | 1.05M | 128K | $5 / $30 |
|
|
199
|
+
| Google | `gemini-3.1-pro-preview` | 1.05M | 65K | $2 / $12 |
|
|
200
|
+
| Google | `gemini-3.8-flash` | 1.05M | 65K | $0.75 / $3.75 |
|
|
201
|
+
| DeepSeek | `deepseek-flash` | 1.05M | 393K | $0.30 / $1.20 |
|
|
202
|
+
| Mistral | `mistral-medium-3-5` | 256K | - | $1.50 / $7.50 |
|
|
203
|
+
| xAI | `grok-4.7` | 500K | - | $2 / $6 |
|
|
204
|
+
| Qwen | `qwen3-coder-plus` | 1M | 65K | $1 / $5 |
|
|
205
|
+
| Meta | `llama-4-maverick` | 1M | - | - |
|
|
206
|
+
|
|
207
|
+
Prices are list prices for the base tier; several models charge a higher rate above a prompt
|
|
208
|
+
size, which `ctxman --estimate-cost` applies. `ctxman --list-llms` also shows each model's status
|
|
209
|
+
(preview, legacy, deprecated) and `--list-llms --all` adds retired models. Earlier ids such as
|
|
210
|
+
`claude-sonnet-4.5` still resolve through aliases. `claude-sonnet-5-5` is the default model of the
|
|
211
|
+
wizard, the built-in templates and profiles, and `ctxman count`.
|
|
129
212
|
|
|
130
213
|
Custom models supported via `.ctxman/custom-profiles.json`
|
|
131
214
|
|
|
215
|
+
#### Token counts per model
|
|
216
|
+
|
|
217
|
+
ctxman counts with tiktoken, which is installed with it, using the target model's encoding:
|
|
218
|
+
`o200k_base` for OpenAI models since GPT-4o and `cl100k_base` otherwise. The counts are exact for
|
|
219
|
+
OpenAI models up to GPT-5.x. Claude, Gemini and the other vendors' models use their own
|
|
220
|
+
tokenizers (and OpenAI has not published GPT-6's encoding), so their counts are approximate.
|
|
221
|
+
`ctxman count` counts a project, or piped text, for one model and checks it against the window;
|
|
222
|
+
with `--api` it counts Claude models exactly through Anthropic's count_tokens API:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
ctxman count --model gpt-5.5 # exact (o200k_base)
|
|
226
|
+
ctxman count --model claude-sonnet-5-5 # approximate, suggests --api
|
|
227
|
+
ctxman count --model claude-sonnet-5-5 --api # exact; needs @anthropic-ai/sdk and ANTHROPIC_API_KEY
|
|
228
|
+
ctxman count - --model claude-opus-5-5 --api < digest.txt # piped text
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
`--api` sends the (secret-redacted) text to Anthropic; counting is free and generates nothing.
|
|
232
|
+
|
|
233
|
+
### 📦 Pack a Codebase into One Prompt
|
|
234
|
+
|
|
235
|
+
`ctxman pack` writes the directory tree, then every file, then your instructions, as one document
|
|
236
|
+
for a model: Anthropic's `<documents>` XML by default, or Markdown, plain text or JSON.
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
ctxman pack -o context.xml # tree + every file, Anthropic XML
|
|
240
|
+
ctxman pack --style markdown --copy # Markdown to the clipboard
|
|
241
|
+
ctxman pack --compress --budget 100k --instructions task.md
|
|
242
|
+
git ls-files -z -- '*.py' | ctxman pack --stdin -0 --line-numbers
|
|
243
|
+
ctxman pack --target-model gpt-6.1-sol --max-tokens 120k -q -o ctx.xml # CI guard, exit 2
|
|
244
|
+
ctxman pack --split 150k -o context.xml # context.1.xml, context.2.xml, ...
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
`--compress` keeps signatures and replaces function bodies with a one-line placeholder,
|
|
248
|
+
`--budget` fills the budget with the files `ctxman map` ranks highest and never goes over, and
|
|
249
|
+
secrets are redacted. Your instructions go last, after the long material, as Anthropic recommends
|
|
250
|
+
for long context. Details: [docs/commands/pack.md](docs/commands/pack.md).
|
|
251
|
+
|
|
252
|
+
### 🗺️ Repository Map
|
|
253
|
+
|
|
254
|
+
The shape of a codebase in a fixed token budget: the most important files, ranked by PageRank
|
|
255
|
+
over the import graph (JS/TS, Python, Go, Java/Kotlin/Scala, C#, PHP, Ruby, C/C++, Rust), recent
|
|
256
|
+
git activity and symbol references, with one line per function (line, signature, tokens).
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
ctxman map # 2048 tokens of the current project
|
|
260
|
+
ctxman map --tokens 4096 --style markdown
|
|
261
|
+
ctxman map --focus src/server.js # rank around the file you are working on
|
|
262
|
+
ctxman map --important-last -o map.txt # best files last, next to your question
|
|
263
|
+
ctxman map --graph --style dot | dot -Tsvg > deps.svg
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Details: [docs/commands/map.md](docs/commands/map.md).
|
|
267
|
+
|
|
268
|
+
### 🔍 Pull-Request Context
|
|
269
|
+
|
|
270
|
+
Everything a reviewer (or a model) needs about a branch, in one document: summary, commit log,
|
|
271
|
+
changed files, the full source of every changed method, deleted methods, the diff and related
|
|
272
|
+
tests, with your question last.
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
ctxman pr # HEAD against origin/HEAD, main or master
|
|
276
|
+
ctxman pr --base release/2.x --budget 30k # drops the least important parts to fit
|
|
277
|
+
ctxman pr --staged --ask "Is this safe to merge?" --copy
|
|
278
|
+
ctxman pr --style xml -o review.xml
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Details: [docs/commands/pr.md](docs/commands/pr.md).
|
|
282
|
+
|
|
283
|
+
### 🧭 Why Is the Code Like This?
|
|
284
|
+
|
|
285
|
+
The local, offline answer to "why is this here?": `ctxman why` collects what git and the
|
|
286
|
+
repository record about a file, a function or a line range.
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
ctxman why src/cart.js:total # function / method / class (Class.method)
|
|
290
|
+
ctxman why src/cart.js#L40-L72 --patches # line range, with each commit's diff
|
|
291
|
+
ctxman why lib/server.js --since "1 year ago" # whole file, following renames
|
|
292
|
+
ctxman why src/cart.js:total --ask "Why round here?" --budget 8k --copy
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
It gathers the commits that changed the code with their full messages, the issues, PRs and
|
|
296
|
+
tickets they reference (linked for GitHub, GitLab and Bitbucket), co-authors and reviewers, blame
|
|
297
|
+
ownership, files that usually change with it, ADRs, docs, changelog entries and comments that
|
|
298
|
+
mention it, TODOs inside it and the tests that use it, with secrets redacted. Platforms such as
|
|
299
|
+
Unblocked answer this from Slack, Jira and Confluence on their servers; ctxman covers what git and
|
|
300
|
+
the repository know, on your machine. Details: [docs/commands/why.md](docs/commands/why.md).
|
|
301
|
+
|
|
302
|
+
### 🔎 Ranked Search and Symbols
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
ctxman search "parse config file" # BM25 over functions and code chunks
|
|
306
|
+
ctxman search getUserName --limit 5 --json
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
`getUserName`, `get_user_name` and `get-user-name` all match "get user name". The same engine
|
|
310
|
+
backs the MCP `search_code` tool (`type: "ranked"`), and `get_symbol` returns a function's full
|
|
311
|
+
source by name. Details: [docs/commands/search.md](docs/commands/search.md).
|
|
312
|
+
|
|
313
|
+
### 🔌 MCP Server Setup
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
ctxman mcp install --client claude-desktop # or claude-code, cursor, vscode, windsurf
|
|
317
|
+
ctxman mcp install --client claude-code --scope project --root .
|
|
318
|
+
ctxman mcp config --client cursor # print the snippet only
|
|
319
|
+
ctxman mcp # run the server (stdio)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
The installer merges into the client's configuration and keeps a `.bak` of the previous file.
|
|
323
|
+
`--root` confines every tool to one directory. Tools: `analyze_codebase`, `generate_context`,
|
|
324
|
+
`git_diff`, `search_code`, `list_methods`, `repo_map`, `pr_context`, `get_symbol`,
|
|
325
|
+
`count_tokens`, `explain_history`, `pack_context`. Details:
|
|
326
|
+
[docs/commands/mcp.md](docs/commands/mcp.md).
|
|
327
|
+
|
|
328
|
+
### 🛡️ Export Policy and Audit Log
|
|
329
|
+
|
|
330
|
+
A policy in the repository (`.ctxman/policy.json`), or one an organisation points to with
|
|
331
|
+
`CTXMAN_POLICY`, applies to the CLI, the REST API and the MCP server alike:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
ctxman policy init # starter policy: deny .env, keys and secrets/, require redaction
|
|
335
|
+
ctxman policy check # validate and show the effective policy
|
|
336
|
+
ctxman audit # what was exported, when, by whom, how many tokens
|
|
337
|
+
ctxman --cli --respect-ignore-files .cursorignore,.aiexclude # honour other AI tools' ignore files
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Denied files never leave the analysis, `--no-redact` and oversized exports are refused (exit
|
|
341
|
+
code 3), and every export is appended to an audit log with a hash of what was written, never the
|
|
342
|
+
content. It is a team and organisation control, not a barrier against a local user. Details:
|
|
343
|
+
[docs/commands/policy.md](docs/commands/policy.md).
|
|
344
|
+
|
|
345
|
+
### 🤖 CI and Docker
|
|
346
|
+
|
|
347
|
+
```yaml
|
|
348
|
+
# .github/workflows/ctxman.yml
|
|
349
|
+
- uses: hakkisagdic/ctxman@main # pin a release tag or commit
|
|
350
|
+
with:
|
|
351
|
+
changed-since: ${{ github.event.pull_request.base.sha }}
|
|
352
|
+
max-tokens: 50000 # fail the job above this budget
|
|
353
|
+
target-model: claude-sonnet-5-5
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
docker build -t ctxman .
|
|
358
|
+
docker run --rm -v "$PWD:/work" ctxman --cli
|
|
359
|
+
docker run -i --rm -v "$PWD:/work" ctxman mcp --root /work # MCP over stdio
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Details: [docs/commands/ci.md](docs/commands/ci.md).
|
|
363
|
+
|
|
132
364
|
### 🔀 Git Integration (v3.0.0)
|
|
365
|
+
|
|
133
366
|
```bash
|
|
134
367
|
# Analyze only uncommitted changes
|
|
135
368
|
ctxman --changed-only
|
|
@@ -139,8 +372,8 @@ ctxman --changed-since main
|
|
|
139
372
|
ctxman --changed-since HEAD~5
|
|
140
373
|
ctxman --changed-since v2.3.0
|
|
141
374
|
|
|
142
|
-
#
|
|
143
|
-
ctxman --changed-only
|
|
375
|
+
# Only the uncommitted changes
|
|
376
|
+
ctxman --changed-only
|
|
144
377
|
|
|
145
378
|
# Output:
|
|
146
379
|
# 🔀 Git Integration - Analyzing Changed Files
|
|
@@ -151,6 +384,7 @@ ctxman --changed-only --with-authors
|
|
|
151
384
|
```
|
|
152
385
|
|
|
153
386
|
### 👁️ Watch Mode (v3.0.0)
|
|
387
|
+
|
|
154
388
|
```bash
|
|
155
389
|
# Start watch mode
|
|
156
390
|
ctxman watch
|
|
@@ -169,6 +403,7 @@ ctxman watch --debounce 2000
|
|
|
169
403
|
```
|
|
170
404
|
|
|
171
405
|
### 🌐 API Server (v3.0.0)
|
|
406
|
+
|
|
172
407
|
```bash
|
|
173
408
|
# Start API server
|
|
174
409
|
ctxman serve
|
|
@@ -191,6 +426,7 @@ curl http://localhost:3000/api/v1/diff?since=main
|
|
|
191
426
|
```
|
|
192
427
|
|
|
193
428
|
### Wrapper Script Usage
|
|
429
|
+
|
|
194
430
|
```bash
|
|
195
431
|
# Using the NPM package globally
|
|
196
432
|
ctxman
|
|
@@ -209,7 +445,7 @@ Ctxman includes real-world test repositories for validation:
|
|
|
209
445
|
cd test-repos/express
|
|
210
446
|
|
|
211
447
|
# Run full test suite
|
|
212
|
-
ctxman --cli -m --target-model claude-sonnet-
|
|
448
|
+
ctxman --cli -m --target-model claude-sonnet-5-5
|
|
213
449
|
|
|
214
450
|
# Git integration test
|
|
215
451
|
ctxman --changed-since v5.0.0
|
|
@@ -225,6 +461,7 @@ See [test-repos/README.md](test-repos/README.md) for complete testing guide.
|
|
|
225
461
|
Complete manual testing guide available at [docs/MANUAL-TESTING-v3.0.md](docs/MANUAL-TESTING-v3.0.md)
|
|
226
462
|
|
|
227
463
|
Includes:
|
|
464
|
+
|
|
228
465
|
- ✅ 50+ test scenarios for all v3.0.0 features
|
|
229
466
|
- ✅ API endpoint validation
|
|
230
467
|
- ✅ Git integration testing
|
|
@@ -250,6 +487,7 @@ npm run test:watch
|
|
|
250
487
|
The tool is configured to focus on **core application logic only**:
|
|
251
488
|
|
|
252
489
|
### ✅ Included (64 JS files, ~181k tokens)
|
|
490
|
+
|
|
253
491
|
- Core MCP server implementation (`utility-mcp/src/`)
|
|
254
492
|
- Authentication and security layers
|
|
255
493
|
- Request handlers and routing
|
|
@@ -259,6 +497,7 @@ The tool is configured to focus on **core application logic only**:
|
|
|
259
497
|
- Error handling and monitoring
|
|
260
498
|
|
|
261
499
|
### 🚫 Excluded via context ignore rules
|
|
500
|
+
|
|
262
501
|
- Documentation files (`.md`, `.txt`)
|
|
263
502
|
- Configuration files (`.json`, `.yml`)
|
|
264
503
|
- Infrastructure and deployment files
|
|
@@ -271,12 +510,13 @@ The tool is configured to focus on **core application logic only**:
|
|
|
271
510
|
## Usage
|
|
272
511
|
|
|
273
512
|
### Basic Analysis
|
|
513
|
+
|
|
274
514
|
```bash
|
|
275
515
|
# Interactive analysis with export selection
|
|
276
516
|
ctxman
|
|
277
517
|
|
|
278
|
-
#
|
|
279
|
-
ctxman --
|
|
518
|
+
# List every analysed file with its token count
|
|
519
|
+
ctxman --cli --verbose
|
|
280
520
|
|
|
281
521
|
# With detailed JSON report
|
|
282
522
|
ctxman --save-report
|
|
@@ -302,7 +542,7 @@ ctxman
|
|
|
302
542
|
# 2) Generate LLM context file (llm-context.json)
|
|
303
543
|
# 3) Copy LLM context to clipboard
|
|
304
544
|
# 4) No export (skip)
|
|
305
|
-
#
|
|
545
|
+
#
|
|
306
546
|
# 🤔 Which export option would you like? (1-4):
|
|
307
547
|
```
|
|
308
548
|
|
|
@@ -313,22 +553,26 @@ This interactive mode ensures you never miss the opportunity to export your anal
|
|
|
313
553
|
The token calculator supports two complementary filtering modes:
|
|
314
554
|
|
|
315
555
|
### EXCLUDE Mode (.contextignore)
|
|
556
|
+
|
|
316
557
|
- **Default mode** when only `.contextignore` exists
|
|
317
558
|
- Includes all files **except** those matching ignore patterns
|
|
318
559
|
- Traditional gitignore-style exclusion logic
|
|
319
560
|
|
|
320
|
-
### INCLUDE Mode (.contextinclude)
|
|
561
|
+
### INCLUDE Mode (.contextinclude)
|
|
562
|
+
|
|
321
563
|
- **Priority mode** - when `.contextinclude` exists, `.contextignore` is ignored
|
|
322
564
|
- Includes **only** files matching include patterns
|
|
323
565
|
- More precise control for specific file selection
|
|
324
566
|
- Perfect for creating focused analysis sets
|
|
325
567
|
|
|
326
568
|
### Mode Priority
|
|
569
|
+
|
|
327
570
|
1. If `.contextinclude` exists → **INCLUDE mode** (ignore `.contextignore`)
|
|
328
571
|
2. If only `.contextignore` exists → **EXCLUDE mode**
|
|
329
572
|
3. If neither exists → Include all files (respect `.gitignore` only)
|
|
330
573
|
|
|
331
574
|
### Example Usage
|
|
575
|
+
|
|
332
576
|
```bash
|
|
333
577
|
# EXCLUDE mode: Include everything except patterns in .contextignore
|
|
334
578
|
rm .contextinclude # Remove include file
|
|
@@ -340,42 +584,38 @@ ctxman
|
|
|
340
584
|
```
|
|
341
585
|
|
|
342
586
|
### Help and Options
|
|
587
|
+
|
|
343
588
|
```bash
|
|
344
589
|
ctxman --help
|
|
345
590
|
```
|
|
346
591
|
|
|
347
592
|
### Available Options
|
|
593
|
+
|
|
348
594
|
- `--save-report`, `-s` - Save detailed JSON report
|
|
349
|
-
- `--
|
|
595
|
+
- `--verbose`, `-v` - List every analysed file with its token count
|
|
350
596
|
- `--context-export` - Generate LLM context file list (saves as llm-context.json)
|
|
351
597
|
- `--context-clipboard` - Copy LLM context directly to clipboard
|
|
352
|
-
- `--
|
|
598
|
+
- `-o`, `--output FORMAT` - Context format: json (default), toon, yaml, markdown, csv, xml
|
|
353
599
|
- `--help`, `-h` - Show help message
|
|
354
600
|
|
|
355
601
|
## LLM Context Export
|
|
356
602
|
|
|
357
|
-
The token calculator can generate optimized file lists for LLM consumption
|
|
603
|
+
The token calculator can generate optimized file lists for LLM consumption.
|
|
358
604
|
|
|
359
|
-
###
|
|
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`
|
|
605
|
+
### Context Format
|
|
365
606
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
- **
|
|
369
|
-
- **
|
|
370
|
-
- **Usage**: `--
|
|
607
|
+
- **Content**: Project metadata and file paths grouped by directory; `-m` lists methods with
|
|
608
|
+
line numbers and token counts instead
|
|
609
|
+
- **Format**: JSON by default; `-o toon|yaml|markdown|csv|xml` picks another encoding
|
|
610
|
+
- **Same everywhere**: The clipboard gets exactly what `llm-context.<format>` contains
|
|
611
|
+
- **Usage**: `--context-clipboard` or `--context-export`
|
|
371
612
|
|
|
372
613
|
### Features
|
|
373
|
-
|
|
374
|
-
- **Directory grouping** -
|
|
375
|
-
- **
|
|
376
|
-
- **
|
|
377
|
-
- **Cross-platform clipboard** - Works on macOS, Linux, and Windows
|
|
378
|
-
- **Multiple output formats** - JSON file or clipboard ready text
|
|
614
|
+
|
|
615
|
+
- **Directory grouping** - Each directory is listed once with its file names
|
|
616
|
+
- **TOON encoding** - `-o toon` uses the official TOON encoder: fewer tokens than JSON
|
|
617
|
+
- **Method level** - `-m` adds every method with its line number and token count
|
|
618
|
+
- **Cross-platform clipboard** - Works on macOS, Linux, and Windows, and falls back to a file
|
|
379
619
|
|
|
380
620
|
### Usage
|
|
381
621
|
|
|
@@ -386,16 +626,14 @@ ctxman --context-export
|
|
|
386
626
|
# Copy minimal context directly to clipboard (2.3k chars JSON - identical to file)
|
|
387
627
|
ctxman --context-clipboard
|
|
388
628
|
|
|
389
|
-
# Copy detailed context to clipboard (8.6k chars)
|
|
390
|
-
ctxman --detailed-context --context-clipboard
|
|
391
|
-
|
|
392
629
|
# Combine with regular analysis
|
|
393
630
|
ctxman --save-report --context-clipboard
|
|
394
631
|
```
|
|
395
632
|
|
|
396
633
|
### Output Format Examples
|
|
397
634
|
|
|
398
|
-
**
|
|
635
|
+
**JSON (default):**
|
|
636
|
+
|
|
399
637
|
```json
|
|
400
638
|
{
|
|
401
639
|
"project": {
|
|
@@ -404,54 +642,26 @@ ctxman --save-report --context-clipboard
|
|
|
404
642
|
"totalTokens": 181480
|
|
405
643
|
},
|
|
406
644
|
"paths": {
|
|
407
|
-
"utility-mcp/src/server/": [
|
|
408
|
-
"CloudStackUtilityMCP.js"
|
|
409
|
-
],
|
|
645
|
+
"utility-mcp/src/server/": ["CloudStackUtilityMCP.js"],
|
|
410
646
|
"utility-mcp/src/handlers/": [
|
|
411
647
|
"workflow-handlers.js",
|
|
412
648
|
"tool-handlers.js",
|
|
413
649
|
"analytics-handler.js"
|
|
414
650
|
],
|
|
415
|
-
"utility-mcp/src/utils/": [
|
|
416
|
-
"security.js",
|
|
417
|
-
"usage-tracker.js",
|
|
418
|
-
"cache-warming.js"
|
|
419
|
-
]
|
|
651
|
+
"utility-mcp/src/utils/": ["security.js", "usage-tracker.js", "cache-warming.js"]
|
|
420
652
|
}
|
|
421
653
|
}
|
|
422
654
|
```
|
|
423
655
|
|
|
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
656
|
**Use Cases**
|
|
441
657
|
|
|
442
|
-
**Compact Format (2.3k chars JSON):**
|
|
443
658
|
1. **LLM Integration** - Structured data for AI assistants with complete project context
|
|
444
|
-
2. **Programmatic Processing** - JSON format for automated tools and scripts
|
|
659
|
+
2. **Programmatic Processing** - JSON format for automated tools and scripts
|
|
445
660
|
3. **Context Sharing** - Identical format in clipboard and file exports
|
|
446
661
|
4. **Development Workflows** - Consistent structure for CI/CD and automation
|
|
447
662
|
|
|
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
663
|
**General Use Cases:**
|
|
664
|
+
|
|
455
665
|
- Development workflow integration
|
|
456
666
|
- CI/CD pipeline context generation
|
|
457
667
|
- Automated documentation updates
|
|
@@ -464,6 +674,7 @@ Context-manager now supports generating GitIngest-style digest files - a single,
|
|
|
464
674
|
### What is GitIngest Format?
|
|
465
675
|
|
|
466
676
|
GitIngest format consolidates your entire codebase into a single text file with:
|
|
677
|
+
|
|
467
678
|
- Project summary and statistics
|
|
468
679
|
- Visual directory tree structure
|
|
469
680
|
- Complete file contents with clear separators
|
|
@@ -495,6 +706,7 @@ ctxman --gitingest-from-context my-context.json
|
|
|
495
706
|
```
|
|
496
707
|
|
|
497
708
|
**Why use JSON-based digest?**
|
|
709
|
+
|
|
498
710
|
- ⚡ **Performance**: Instant digest generation without re-scanning
|
|
499
711
|
- 🔄 **Reusability**: Generate multiple digests from one analysis
|
|
500
712
|
- 📦 **Workflow**: Separate analysis from export steps
|
|
@@ -535,6 +747,9 @@ FILE: src/utils.js
|
|
|
535
747
|
- **Token Estimates**: Formatted as "1.2k" or "1.5M"
|
|
536
748
|
- **Sorted Output**: Files sorted by token count (largest first)
|
|
537
749
|
- **Filter Compatible**: Respects all `.gitignore` and context ignore rules
|
|
750
|
+
- **Secret Redaction**: Known credential formats (AWS access key IDs, GitHub/GitLab/npm/Slack
|
|
751
|
+
tokens, Stripe live keys, Google/OpenAI/Anthropic API keys, PEM private keys) are replaced
|
|
752
|
+
with `[REDACTED:<type>]` and counted in the console output. Pass `--no-redact` to keep them.
|
|
538
753
|
|
|
539
754
|
### Use Cases
|
|
540
755
|
|
|
@@ -591,6 +806,7 @@ utility-mcp/src/**/*.js
|
|
|
591
806
|
### Creating Custom Configurations
|
|
592
807
|
|
|
593
808
|
**For EXCLUDE mode** (edit `.contextignore`):
|
|
809
|
+
|
|
594
810
|
```bash
|
|
595
811
|
# Remove lines to include more file types
|
|
596
812
|
# Add patterns to exclude specific files
|
|
@@ -604,6 +820,7 @@ specific-directory/**
|
|
|
604
820
|
```
|
|
605
821
|
|
|
606
822
|
**For INCLUDE mode** (create `.contextinclude`):
|
|
823
|
+
|
|
607
824
|
```bash
|
|
608
825
|
# Include specific files or patterns
|
|
609
826
|
src/**/*.js # All JS files in src
|
|
@@ -625,14 +842,17 @@ src/**/*.js
|
|
|
625
842
|
|
|
626
843
|
## Installation
|
|
627
844
|
|
|
628
|
-
|
|
845
|
+
tiktoken is a dependency of ctxman, so token counting works out of the box (exact for OpenAI
|
|
846
|
+
models, approximate for other vendors; see [Token counts per model](#token-counts-per-model)). If
|
|
847
|
+
tiktoken cannot be loaded, the tool falls back to smart estimation (~95% accuracy).
|
|
848
|
+
|
|
849
|
+
For exact Claude counts with `ctxman count --api`, install Anthropic's SDK and set your API key:
|
|
629
850
|
|
|
630
851
|
```bash
|
|
631
|
-
npm install
|
|
852
|
+
npm install -g @anthropic-ai/sdk # next to a global ctxman; without -g for a project install
|
|
853
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
632
854
|
```
|
|
633
855
|
|
|
634
|
-
Without tiktoken, the tool uses smart estimation (~95% accuracy).
|
|
635
|
-
|
|
636
856
|
## Output Example
|
|
637
857
|
|
|
638
858
|
```
|
|
@@ -664,17 +884,18 @@ Extension Files Tokens Size (KB) Lines
|
|
|
664
884
|
## Context Management
|
|
665
885
|
|
|
666
886
|
Perfect for LLM context window optimization:
|
|
887
|
+
|
|
667
888
|
- **181k tokens** = Core application logic only
|
|
668
889
|
- **Clean analysis** = No noise from docs, configs, or build files
|
|
669
890
|
- **Focused development** = Essential code for AI-assisted development
|
|
670
891
|
- **Context efficiency** = Maximum useful code per token
|
|
671
892
|
- **Dual mode flexibility** = Precise include/exclude control
|
|
672
|
-
- **
|
|
673
|
-
- **Detailed export** = 8.6k chars for comprehensive analysis when needed
|
|
893
|
+
- **Compact export** = Paths grouped by directory, in JSON or TOON, for frequent AI interactions
|
|
674
894
|
|
|
675
895
|
## Integration
|
|
676
896
|
|
|
677
897
|
You can integrate this tool into:
|
|
898
|
+
|
|
678
899
|
- CI/CD pipelines for code size monitoring
|
|
679
900
|
- Pre-commit hooks for token budget checks
|
|
680
901
|
- Documentation generation workflows
|
|
@@ -685,22 +906,26 @@ You can integrate this tool into:
|
|
|
685
906
|
## Troubleshooting
|
|
686
907
|
|
|
687
908
|
### Include vs Exclude Mode Issues
|
|
909
|
+
|
|
688
910
|
- **INCLUDE mode active**: Remove `.contextinclude` to use EXCLUDE mode
|
|
689
911
|
- **Wrong files included**: Check if `.contextinclude` exists (takes priority)
|
|
690
912
|
- **Mode confusion**: Use verbose mode to see which mode is active
|
|
691
913
|
|
|
692
914
|
### Patterns Not Working
|
|
915
|
+
|
|
693
916
|
- Ensure no inline comments in ignore/include pattern files
|
|
694
917
|
- Use file patterns (`docs/**`) instead of directory patterns (`docs/`)
|
|
695
918
|
- Test specific patterns with verbose mode
|
|
696
919
|
- Check pattern syntax: `**` for recursive, `*` for single level
|
|
697
920
|
|
|
698
921
|
### Token Count Issues
|
|
922
|
+
|
|
699
923
|
- **Too high**: Review included files with verbose mode, add exclusion patterns
|
|
700
924
|
- **Too low**: Check if important files are excluded, review patterns
|
|
701
925
|
- **Inconsistent**: Verify which mode is active (include vs exclude)
|
|
702
926
|
|
|
703
927
|
### Missing Expected Files
|
|
928
|
+
|
|
704
929
|
- Check if files are excluded by `.gitignore` (always respected)
|
|
705
930
|
- Verify calculator ignore/include patterns
|
|
706
931
|
- Ensure files are recognized as text files
|
|
@@ -710,7 +935,7 @@ You can integrate this tool into:
|
|
|
710
935
|
|
|
711
936
|
LLM context manager with method-level filtering and token optimization. The ultimate tool for AI-assisted development.
|
|
712
937
|
|
|
713
|
-
|
|
938
|
+
_Created by Hakkı Sağdıç_
|
|
714
939
|
|
|
715
940
|
## 🚀 Features
|
|
716
941
|
|
|
@@ -718,15 +943,16 @@ LLM context manager with method-level filtering and token optimization. The ulti
|
|
|
718
943
|
🔧 **Method-level analysis** - Extract and analyze specific methods from JavaScript/TypeScript/Rust/C#/Go/Java
|
|
719
944
|
📋 **Dual filtering system** - Include/exclude files and methods with pattern matching
|
|
720
945
|
📊 **LLM context optimization** - Generate ultra-compact context for AI assistants
|
|
721
|
-
🎯 **
|
|
946
|
+
🎯 **Token counting** - tiktoken with the target model's encoding (exact for OpenAI models)
|
|
722
947
|
📤 **Multiple export formats** - JSON reports, clipboard, file exports
|
|
723
948
|
📦 **NPM package** - Use programmatically or as global CLI tool
|
|
724
949
|
🔍 **Pattern matching** - Wildcards and regex support for flexible filtering
|
|
725
|
-
⚡ **Performance optimized** - 36% smaller codebase with enhanced functionality
|
|
950
|
+
⚡ **Performance optimized** - 36% smaller codebase with enhanced functionality
|
|
726
951
|
|
|
727
952
|
## 📦 Installation
|
|
728
953
|
|
|
729
954
|
### Option 1: NPM Package (Recommended)
|
|
955
|
+
|
|
730
956
|
```bash
|
|
731
957
|
# Local installation
|
|
732
958
|
npm install ctxman
|
|
@@ -739,6 +965,7 @@ ctxman --help
|
|
|
739
965
|
```
|
|
740
966
|
|
|
741
967
|
### Option 2: Direct Usage
|
|
968
|
+
|
|
742
969
|
```bash
|
|
743
970
|
# Clone and use directly
|
|
744
971
|
git clone <repository>
|
|
@@ -749,6 +976,7 @@ node token-calculator.js --help
|
|
|
749
976
|
## 🎯 Quick Start
|
|
750
977
|
|
|
751
978
|
### Basic Analysis
|
|
979
|
+
|
|
752
980
|
```bash
|
|
753
981
|
# Interactive analysis with export selection
|
|
754
982
|
ctxman
|
|
@@ -764,6 +992,7 @@ ctxman --method-level --save-report --verbose
|
|
|
764
992
|
```
|
|
765
993
|
|
|
766
994
|
### Advanced Usage
|
|
995
|
+
|
|
767
996
|
```bash
|
|
768
997
|
# Focus on specific methods only
|
|
769
998
|
echo "calculateTokens\nhandleRequest\n*Validator" > .methodinclude
|
|
@@ -802,14 +1031,14 @@ const { TokenAnalyzer } = require('ctxman');
|
|
|
802
1031
|
|
|
803
1032
|
// Basic file-level analysis
|
|
804
1033
|
const analyzer = new TokenAnalyzer('./src', {
|
|
805
|
-
|
|
806
|
-
|
|
1034
|
+
methodLevel: false,
|
|
1035
|
+
verbose: true,
|
|
807
1036
|
});
|
|
808
1037
|
|
|
809
1038
|
// Method-level analysis
|
|
810
1039
|
const methodAnalyzer = new TokenAnalyzer('./src', {
|
|
811
|
-
|
|
812
|
-
|
|
1040
|
+
methodLevel: true,
|
|
1041
|
+
saveReport: true,
|
|
813
1042
|
});
|
|
814
1043
|
|
|
815
1044
|
analyzer.run();
|
|
@@ -820,11 +1049,13 @@ analyzer.run();
|
|
|
820
1049
|
### File-Level Filtering
|
|
821
1050
|
|
|
822
1051
|
**Priority Order:**
|
|
1052
|
+
|
|
823
1053
|
1. `.gitignore` (project root) - Standard git exclusions (always respected)
|
|
824
1054
|
2. `.contextinclude` - INCLUDE mode (highest priority for files)
|
|
825
1055
|
3. `.contextignore` - EXCLUDE mode (fallback for files)
|
|
826
1056
|
|
|
827
1057
|
**`.contextinclude`** - Include only these files:
|
|
1058
|
+
|
|
828
1059
|
```bash
|
|
829
1060
|
# Include only core JavaScript files
|
|
830
1061
|
utility-mcp/src/**/*.js
|
|
@@ -832,7 +1063,8 @@ utility-mcp/src/**/*.js
|
|
|
832
1063
|
!utility-mcp/src/workflows/**
|
|
833
1064
|
```
|
|
834
1065
|
|
|
835
|
-
**`.contextignore`** - Exclude these files:
|
|
1066
|
+
**`.contextignore`** - Exclude these files:
|
|
1067
|
+
|
|
836
1068
|
```bash
|
|
837
1069
|
# Exclude documentation and config
|
|
838
1070
|
**/*.md
|
|
@@ -846,6 +1078,7 @@ test/
|
|
|
846
1078
|
### Method-Level Filtering
|
|
847
1079
|
|
|
848
1080
|
**`.methodinclude`** - Include only these methods:
|
|
1081
|
+
|
|
849
1082
|
```bash
|
|
850
1083
|
# Core business logic methods
|
|
851
1084
|
calculateTokens
|
|
@@ -863,6 +1096,7 @@ TokenCalculator.* # All methods in TokenCalculator class
|
|
|
863
1096
|
```
|
|
864
1097
|
|
|
865
1098
|
**`.methodignore`** - Exclude these methods:
|
|
1099
|
+
|
|
866
1100
|
```bash
|
|
867
1101
|
# Utility and debug methods
|
|
868
1102
|
console
|
|
@@ -879,17 +1113,18 @@ utils.debugLog
|
|
|
879
1113
|
|
|
880
1114
|
### Pattern Syntax
|
|
881
1115
|
|
|
882
|
-
| Pattern
|
|
883
|
-
|
|
884
|
-
| `methodName`
|
|
885
|
-
| `*pattern*`
|
|
886
|
-
| `Class.*`
|
|
887
|
-
| `file.method` | Specific file method | `server.handleRequest`
|
|
888
|
-
| `!pattern`
|
|
1116
|
+
| Pattern | Description | Example |
|
|
1117
|
+
| ------------- | -------------------- | ----------------------------------- |
|
|
1118
|
+
| `methodName` | Exact match | `calculateTokens` |
|
|
1119
|
+
| `*pattern*` | Contains pattern | `*Handler` matches `requestHandler` |
|
|
1120
|
+
| `Class.*` | All methods in class | `TokenCalculator.*` |
|
|
1121
|
+
| `file.method` | Specific file method | `server.handleRequest` |
|
|
1122
|
+
| `!pattern` | Negation (exclude) | `!*test*` |
|
|
889
1123
|
|
|
890
1124
|
## 📤 Output Formats
|
|
891
1125
|
|
|
892
1126
|
### 1. File-Level Context (Default)
|
|
1127
|
+
|
|
893
1128
|
**Use case:** General codebase analysis, file organization
|
|
894
1129
|
|
|
895
1130
|
```json
|
|
@@ -907,6 +1142,7 @@ utils.debugLog
|
|
|
907
1142
|
```
|
|
908
1143
|
|
|
909
1144
|
### 2. Method-Level Context (`--method-level`)
|
|
1145
|
+
|
|
910
1146
|
**Use case:** Focused analysis, debugging specific methods, LLM context optimization
|
|
911
1147
|
|
|
912
1148
|
```json
|
|
@@ -918,12 +1154,10 @@ utils.debugLog
|
|
|
918
1154
|
},
|
|
919
1155
|
"methods": {
|
|
920
1156
|
"src/server.js": [
|
|
921
|
-
{"name": "handleRequest", "line": 15, "tokens": 234},
|
|
922
|
-
{"name": "validateInput", "line": 45, "tokens": 156}
|
|
1157
|
+
{ "name": "handleRequest", "line": 15, "tokens": 234 },
|
|
1158
|
+
{ "name": "validateInput", "line": 45, "tokens": 156 }
|
|
923
1159
|
],
|
|
924
|
-
"src/utils.js": [
|
|
925
|
-
{"name": "processData", "line": 12, "tokens": 89}
|
|
926
|
-
]
|
|
1160
|
+
"src/utils.js": [{ "name": "processData", "line": 12, "tokens": 89 }]
|
|
927
1161
|
},
|
|
928
1162
|
"methodStats": {
|
|
929
1163
|
"totalMethods": 150,
|
|
@@ -934,6 +1168,7 @@ utils.debugLog
|
|
|
934
1168
|
```
|
|
935
1169
|
|
|
936
1170
|
### 3. Detailed Report (JSON)
|
|
1171
|
+
|
|
937
1172
|
**Use case:** Comprehensive analysis, CI/CD integration, historical tracking
|
|
938
1173
|
|
|
939
1174
|
```json
|
|
@@ -956,18 +1191,19 @@ utils.debugLog
|
|
|
956
1191
|
|
|
957
1192
|
## CLI Options
|
|
958
1193
|
|
|
959
|
-
| Option
|
|
960
|
-
|
|
961
|
-
| `--save-report`
|
|
962
|
-
| `--verbose`
|
|
963
|
-
| `--context-export`
|
|
964
|
-
| `--context-clipboard` |
|
|
965
|
-
| `--method-level`
|
|
966
|
-
| `--help`
|
|
1194
|
+
| Option | Short | Description |
|
|
1195
|
+
| --------------------- | ----- | ----------------------------------- |
|
|
1196
|
+
| `--save-report` | `-s` | Save detailed JSON report |
|
|
1197
|
+
| `--verbose` | `-v` | Show included files and directories |
|
|
1198
|
+
| `--context-export` | | Generate LLM context file |
|
|
1199
|
+
| `--context-clipboard` | | Copy context to clipboard |
|
|
1200
|
+
| `--method-level` | `-m` | Enable method-level analysis |
|
|
1201
|
+
| `--help` | `-h` | Show help message |
|
|
967
1202
|
|
|
968
1203
|
## 📊 Use Cases & Examples
|
|
969
1204
|
|
|
970
1205
|
### 1. 🤖 LLM Context Optimization
|
|
1206
|
+
|
|
971
1207
|
**Goal:** Generate minimal context for AI assistants
|
|
972
1208
|
|
|
973
1209
|
```bash
|
|
@@ -981,7 +1217,8 @@ ctxman --method-level --context-export
|
|
|
981
1217
|
|
|
982
1218
|
**Result:** 89% smaller context compared to full codebase
|
|
983
1219
|
|
|
984
|
-
### 2. 📊 Codebase Analysis
|
|
1220
|
+
### 2. 📊 Codebase Analysis
|
|
1221
|
+
|
|
985
1222
|
**Goal:** Understand project complexity and structure
|
|
986
1223
|
|
|
987
1224
|
```bash
|
|
@@ -993,6 +1230,7 @@ ctxman --method-level --save-report
|
|
|
993
1230
|
```
|
|
994
1231
|
|
|
995
1232
|
### 3. 🔍 Method-Level Debugging
|
|
1233
|
+
|
|
996
1234
|
**Goal:** Focus on specific problematic methods
|
|
997
1235
|
|
|
998
1236
|
```bash
|
|
@@ -1006,6 +1244,7 @@ ctxman --method-level
|
|
|
1006
1244
|
```
|
|
1007
1245
|
|
|
1008
1246
|
### 4. 🚀 CI/CD Integration
|
|
1247
|
+
|
|
1009
1248
|
**Goal:** Monitor codebase growth and complexity
|
|
1010
1249
|
|
|
1011
1250
|
```bash
|
|
@@ -1017,6 +1256,7 @@ ctxman --method-level --save-report
|
|
|
1017
1256
|
```
|
|
1018
1257
|
|
|
1019
1258
|
### 5. 📈 Code Quality Gates
|
|
1259
|
+
|
|
1020
1260
|
**Goal:** Ensure code stays within token budgets
|
|
1021
1261
|
|
|
1022
1262
|
```bash
|
|
@@ -1032,14 +1272,14 @@ fi
|
|
|
1032
1272
|
|
|
1033
1273
|
### Core Options
|
|
1034
1274
|
|
|
1035
|
-
| Option
|
|
1036
|
-
|
|
1037
|
-
| `--save-report`
|
|
1038
|
-
| `--verbose`
|
|
1039
|
-
| `--context-export`
|
|
1040
|
-
| `--context-clipboard` |
|
|
1041
|
-
| `--method-level`
|
|
1042
|
-
| `--help`
|
|
1275
|
+
| Option | Short | Description | Example |
|
|
1276
|
+
| --------------------- | ----- | ---------------------------- | ---------------------------- |
|
|
1277
|
+
| `--save-report` | `-s` | Save detailed JSON report | `ctxman -s` |
|
|
1278
|
+
| `--verbose` | `-v` | Show included files/methods | `ctxman -v` |
|
|
1279
|
+
| `--context-export` | | Generate LLM context file | `ctxman --context-export` |
|
|
1280
|
+
| `--context-clipboard` | | Copy context to clipboard | `ctxman --context-clipboard` |
|
|
1281
|
+
| `--method-level` | `-m` | Enable method-level analysis | `ctxman -m` |
|
|
1282
|
+
| `--help` | `-h` | Show help message | `ctxman -h` |
|
|
1043
1283
|
|
|
1044
1284
|
### Usage Patterns
|
|
1045
1285
|
|
|
@@ -1058,6 +1298,9 @@ ctxman --save-report --context-export
|
|
|
1058
1298
|
|
|
1059
1299
|
# Development debugging
|
|
1060
1300
|
ctxman --method-level --verbose
|
|
1301
|
+
|
|
1302
|
+
# Token count for one model (exact for Claude with --api)
|
|
1303
|
+
ctxman count --model claude-sonnet-5-5 --api
|
|
1061
1304
|
```
|
|
1062
1305
|
|
|
1063
1306
|
## 💻 Programmatic API
|
|
@@ -1070,7 +1313,7 @@ const { TokenAnalyzer } = require('ctxman');
|
|
|
1070
1313
|
// File-level analysis
|
|
1071
1314
|
const analyzer = new TokenAnalyzer('./src', {
|
|
1072
1315
|
verbose: true,
|
|
1073
|
-
saveReport: true
|
|
1316
|
+
saveReport: true,
|
|
1074
1317
|
});
|
|
1075
1318
|
|
|
1076
1319
|
analyzer.run();
|
|
@@ -1085,7 +1328,7 @@ const { TokenAnalyzer, MethodAnalyzer } = require('ctxman');
|
|
|
1085
1328
|
const analyzer = new TokenAnalyzer('./src', {
|
|
1086
1329
|
methodLevel: true,
|
|
1087
1330
|
contextExport: true,
|
|
1088
|
-
verbose: false
|
|
1331
|
+
verbose: false,
|
|
1089
1332
|
});
|
|
1090
1333
|
|
|
1091
1334
|
analyzer.run();
|
|
@@ -1101,17 +1344,17 @@ const methods = methodAnalyzer.extractMethods(fileContent, 'server.js');
|
|
|
1101
1344
|
const analyzer = new TokenAnalyzer('./src', {
|
|
1102
1345
|
// Enable method-level analysis
|
|
1103
1346
|
methodLevel: true,
|
|
1104
|
-
|
|
1347
|
+
|
|
1105
1348
|
// Output options
|
|
1106
1349
|
saveReport: true,
|
|
1107
1350
|
contextExport: true,
|
|
1108
1351
|
contextToClipboard: true,
|
|
1109
|
-
|
|
1352
|
+
|
|
1110
1353
|
// Verbosity
|
|
1111
1354
|
verbose: true,
|
|
1112
|
-
|
|
1355
|
+
|
|
1113
1356
|
// Compact context (for LLM optimization)
|
|
1114
|
-
compactContext: true
|
|
1357
|
+
compactContext: true,
|
|
1115
1358
|
});
|
|
1116
1359
|
|
|
1117
1360
|
// Access results
|
|
@@ -1125,29 +1368,30 @@ console.log('Analysis complete!');
|
|
|
1125
1368
|
const { MethodAnalyzer, MethodFilterParser } = require('ctxman');
|
|
1126
1369
|
|
|
1127
1370
|
// Create custom method filter
|
|
1128
|
-
const filter = new MethodFilterParser(
|
|
1129
|
-
'./custom-methods.include',
|
|
1130
|
-
'./custom-methods.ignore'
|
|
1131
|
-
);
|
|
1371
|
+
const filter = new MethodFilterParser('./custom-methods.include', './custom-methods.ignore');
|
|
1132
1372
|
|
|
1133
1373
|
// Analyze specific file
|
|
1134
1374
|
const methodAnalyzer = new MethodAnalyzer();
|
|
1135
1375
|
const methods = methodAnalyzer.extractMethods(content, filePath);
|
|
1136
1376
|
|
|
1137
1377
|
// Filter methods
|
|
1138
|
-
const filteredMethods = methods.filter(method =>
|
|
1378
|
+
const filteredMethods = methods.filter((method) =>
|
|
1139
1379
|
filter.shouldIncludeMethod(method.name, fileName)
|
|
1140
1380
|
);
|
|
1141
1381
|
```
|
|
1142
1382
|
|
|
1143
1383
|
## Requirements
|
|
1144
1384
|
|
|
1145
|
-
- **Node.js**:
|
|
1146
|
-
- **tiktoken**: ^1.0.
|
|
1385
|
+
- **Node.js**: 22 or newer (tested on 22 LTS and 24 LTS)
|
|
1386
|
+
- **tiktoken**: ^1.0.22 (installed with ctxman; token counting)
|
|
1387
|
+
- **@anthropic-ai/sdk** (optional, install it yourself; used only by `ctxman count --api`)
|
|
1388
|
+
- **@xenova/transformers** and **@lancedb/lancedb** (optional dependencies, used only by
|
|
1389
|
+
`ctxman ask` for local semantic search). npm installs them by default; skip them with
|
|
1390
|
+
`npm install -g ctxman --omit=optional` if you do not need `ask`.
|
|
1147
1391
|
|
|
1148
1392
|
## License
|
|
1149
1393
|
|
|
1150
|
-
MIT License - see LICENSE
|
|
1394
|
+
MIT License - see [LICENSE](LICENSE) for details
|
|
1151
1395
|
|
|
1152
1396
|
## Contributing
|
|
1153
1397
|
|
|
@@ -1164,4 +1408,4 @@ MIT License - see LICENSE file for details
|
|
|
1164
1408
|
|
|
1165
1409
|
---
|
|
1166
1410
|
|
|
1167
|
-
|
|
1411
|
+
_Created with ❤️ by Hakkı Sağdıç_
|