ctxman 3.0.0 → 3.1.1
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 +381 -136
- package/bin/cli.js +1880 -529
- package/bin/cm-ask.js +18 -67
- package/bin/cm-audit.js +121 -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 +687 -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 +772 -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 +116 -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 +312 -0
- package/lib/policy/enforce.js +125 -0
- package/lib/policy/ignore-files.js +169 -0
- package/lib/policy/index.js +53 -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/ask.js +122 -0
- package/lib/rag/sources/FileDataSource.js +12 -9
- 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 +246 -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 +257 -0
- package/lib/wizards/project-detector.js +572 -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,210 @@ 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`, `check_policy`, `audit_log`, `ask_codebase`.
|
|
326
|
+
Details:
|
|
327
|
+
[docs/commands/mcp.md](docs/commands/mcp.md).
|
|
328
|
+
|
|
329
|
+
### 🛡️ Export Policy and Audit Log
|
|
330
|
+
|
|
331
|
+
A policy in the repository (`.ctxman/policy.json`), or one an organisation points to with
|
|
332
|
+
`CTXMAN_POLICY`, applies to the CLI, the REST API and the MCP server alike:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
ctxman policy init # starter policy: deny .env, keys and secrets/, require redaction
|
|
336
|
+
ctxman policy check # validate and show the effective policy
|
|
337
|
+
ctxman audit # what was exported, when, by whom, how many tokens
|
|
338
|
+
ctxman --cli --respect-ignore-files .cursorignore,.aiexclude # honour other AI tools' ignore files
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Denied files never leave the analysis, `--no-redact` and oversized exports are refused (exit
|
|
342
|
+
code 3), and every export is appended to an audit log with a hash of what was written, never the
|
|
343
|
+
content. It is a team and organisation control, not a barrier against a local user. Details:
|
|
344
|
+
[docs/commands/policy.md](docs/commands/policy.md).
|
|
345
|
+
|
|
346
|
+
### 🤖 CI and Docker
|
|
347
|
+
|
|
348
|
+
```yaml
|
|
349
|
+
# .github/workflows/ctxman.yml
|
|
350
|
+
- uses: hakkisagdic/ctxman@main # pin a release tag or commit
|
|
351
|
+
with:
|
|
352
|
+
changed-since: ${{ github.event.pull_request.base.sha }}
|
|
353
|
+
max-tokens: 50000 # fail the job above this budget
|
|
354
|
+
target-model: claude-sonnet-5-5
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
docker build -t ctxman .
|
|
359
|
+
docker run --rm -v "$PWD:/work" ctxman --cli
|
|
360
|
+
docker run -i --rm -v "$PWD:/work" ctxman mcp --root /work # MCP over stdio
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Details: [docs/commands/ci.md](docs/commands/ci.md).
|
|
364
|
+
|
|
132
365
|
### 🔀 Git Integration (v3.0.0)
|
|
366
|
+
|
|
133
367
|
```bash
|
|
134
368
|
# Analyze only uncommitted changes
|
|
135
369
|
ctxman --changed-only
|
|
@@ -139,8 +373,8 @@ ctxman --changed-since main
|
|
|
139
373
|
ctxman --changed-since HEAD~5
|
|
140
374
|
ctxman --changed-since v2.3.0
|
|
141
375
|
|
|
142
|
-
#
|
|
143
|
-
ctxman --changed-only
|
|
376
|
+
# Only the uncommitted changes
|
|
377
|
+
ctxman --changed-only
|
|
144
378
|
|
|
145
379
|
# Output:
|
|
146
380
|
# 🔀 Git Integration - Analyzing Changed Files
|
|
@@ -151,6 +385,7 @@ ctxman --changed-only --with-authors
|
|
|
151
385
|
```
|
|
152
386
|
|
|
153
387
|
### 👁️ Watch Mode (v3.0.0)
|
|
388
|
+
|
|
154
389
|
```bash
|
|
155
390
|
# Start watch mode
|
|
156
391
|
ctxman watch
|
|
@@ -169,6 +404,7 @@ ctxman watch --debounce 2000
|
|
|
169
404
|
```
|
|
170
405
|
|
|
171
406
|
### 🌐 API Server (v3.0.0)
|
|
407
|
+
|
|
172
408
|
```bash
|
|
173
409
|
# Start API server
|
|
174
410
|
ctxman serve
|
|
@@ -191,6 +427,7 @@ curl http://localhost:3000/api/v1/diff?since=main
|
|
|
191
427
|
```
|
|
192
428
|
|
|
193
429
|
### Wrapper Script Usage
|
|
430
|
+
|
|
194
431
|
```bash
|
|
195
432
|
# Using the NPM package globally
|
|
196
433
|
ctxman
|
|
@@ -209,7 +446,7 @@ Ctxman includes real-world test repositories for validation:
|
|
|
209
446
|
cd test-repos/express
|
|
210
447
|
|
|
211
448
|
# Run full test suite
|
|
212
|
-
ctxman --cli -m --target-model claude-sonnet-
|
|
449
|
+
ctxman --cli -m --target-model claude-sonnet-5-5
|
|
213
450
|
|
|
214
451
|
# Git integration test
|
|
215
452
|
ctxman --changed-since v5.0.0
|
|
@@ -225,6 +462,7 @@ See [test-repos/README.md](test-repos/README.md) for complete testing guide.
|
|
|
225
462
|
Complete manual testing guide available at [docs/MANUAL-TESTING-v3.0.md](docs/MANUAL-TESTING-v3.0.md)
|
|
226
463
|
|
|
227
464
|
Includes:
|
|
465
|
+
|
|
228
466
|
- ✅ 50+ test scenarios for all v3.0.0 features
|
|
229
467
|
- ✅ API endpoint validation
|
|
230
468
|
- ✅ Git integration testing
|
|
@@ -250,6 +488,7 @@ npm run test:watch
|
|
|
250
488
|
The tool is configured to focus on **core application logic only**:
|
|
251
489
|
|
|
252
490
|
### ✅ Included (64 JS files, ~181k tokens)
|
|
491
|
+
|
|
253
492
|
- Core MCP server implementation (`utility-mcp/src/`)
|
|
254
493
|
- Authentication and security layers
|
|
255
494
|
- Request handlers and routing
|
|
@@ -259,6 +498,7 @@ The tool is configured to focus on **core application logic only**:
|
|
|
259
498
|
- Error handling and monitoring
|
|
260
499
|
|
|
261
500
|
### 🚫 Excluded via context ignore rules
|
|
501
|
+
|
|
262
502
|
- Documentation files (`.md`, `.txt`)
|
|
263
503
|
- Configuration files (`.json`, `.yml`)
|
|
264
504
|
- Infrastructure and deployment files
|
|
@@ -271,12 +511,13 @@ The tool is configured to focus on **core application logic only**:
|
|
|
271
511
|
## Usage
|
|
272
512
|
|
|
273
513
|
### Basic Analysis
|
|
514
|
+
|
|
274
515
|
```bash
|
|
275
516
|
# Interactive analysis with export selection
|
|
276
517
|
ctxman
|
|
277
518
|
|
|
278
|
-
#
|
|
279
|
-
ctxman --
|
|
519
|
+
# List every analysed file with its token count
|
|
520
|
+
ctxman --cli --verbose
|
|
280
521
|
|
|
281
522
|
# With detailed JSON report
|
|
282
523
|
ctxman --save-report
|
|
@@ -302,7 +543,7 @@ ctxman
|
|
|
302
543
|
# 2) Generate LLM context file (llm-context.json)
|
|
303
544
|
# 3) Copy LLM context to clipboard
|
|
304
545
|
# 4) No export (skip)
|
|
305
|
-
#
|
|
546
|
+
#
|
|
306
547
|
# 🤔 Which export option would you like? (1-4):
|
|
307
548
|
```
|
|
308
549
|
|
|
@@ -313,22 +554,26 @@ This interactive mode ensures you never miss the opportunity to export your anal
|
|
|
313
554
|
The token calculator supports two complementary filtering modes:
|
|
314
555
|
|
|
315
556
|
### EXCLUDE Mode (.contextignore)
|
|
557
|
+
|
|
316
558
|
- **Default mode** when only `.contextignore` exists
|
|
317
559
|
- Includes all files **except** those matching ignore patterns
|
|
318
560
|
- Traditional gitignore-style exclusion logic
|
|
319
561
|
|
|
320
|
-
### INCLUDE Mode (.contextinclude)
|
|
562
|
+
### INCLUDE Mode (.contextinclude)
|
|
563
|
+
|
|
321
564
|
- **Priority mode** - when `.contextinclude` exists, `.contextignore` is ignored
|
|
322
565
|
- Includes **only** files matching include patterns
|
|
323
566
|
- More precise control for specific file selection
|
|
324
567
|
- Perfect for creating focused analysis sets
|
|
325
568
|
|
|
326
569
|
### Mode Priority
|
|
570
|
+
|
|
327
571
|
1. If `.contextinclude` exists → **INCLUDE mode** (ignore `.contextignore`)
|
|
328
572
|
2. If only `.contextignore` exists → **EXCLUDE mode**
|
|
329
573
|
3. If neither exists → Include all files (respect `.gitignore` only)
|
|
330
574
|
|
|
331
575
|
### Example Usage
|
|
576
|
+
|
|
332
577
|
```bash
|
|
333
578
|
# EXCLUDE mode: Include everything except patterns in .contextignore
|
|
334
579
|
rm .contextinclude # Remove include file
|
|
@@ -340,42 +585,38 @@ ctxman
|
|
|
340
585
|
```
|
|
341
586
|
|
|
342
587
|
### Help and Options
|
|
588
|
+
|
|
343
589
|
```bash
|
|
344
590
|
ctxman --help
|
|
345
591
|
```
|
|
346
592
|
|
|
347
593
|
### Available Options
|
|
594
|
+
|
|
348
595
|
- `--save-report`, `-s` - Save detailed JSON report
|
|
349
|
-
- `--
|
|
596
|
+
- `--verbose`, `-v` - List every analysed file with its token count
|
|
350
597
|
- `--context-export` - Generate LLM context file list (saves as llm-context.json)
|
|
351
598
|
- `--context-clipboard` - Copy LLM context directly to clipboard
|
|
352
|
-
- `--
|
|
599
|
+
- `-o`, `--output FORMAT` - Context format: json (default), toon, yaml, markdown, csv, xml
|
|
353
600
|
- `--help`, `-h` - Show help message
|
|
354
601
|
|
|
355
602
|
## LLM Context Export
|
|
356
603
|
|
|
357
|
-
The token calculator can generate optimized file lists for LLM consumption
|
|
604
|
+
The token calculator can generate optimized file lists for LLM consumption.
|
|
358
605
|
|
|
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`
|
|
606
|
+
### Context Format
|
|
365
607
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
- **
|
|
369
|
-
- **
|
|
370
|
-
- **Usage**: `--
|
|
608
|
+
- **Content**: Project metadata and file paths grouped by directory; `-m` lists methods with
|
|
609
|
+
line numbers and token counts instead
|
|
610
|
+
- **Format**: JSON by default; `-o toon|yaml|markdown|csv|xml` picks another encoding
|
|
611
|
+
- **Same everywhere**: The clipboard gets exactly what `llm-context.<format>` contains
|
|
612
|
+
- **Usage**: `--context-clipboard` or `--context-export`
|
|
371
613
|
|
|
372
614
|
### 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
|
|
615
|
+
|
|
616
|
+
- **Directory grouping** - Each directory is listed once with its file names
|
|
617
|
+
- **TOON encoding** - `-o toon` uses the official TOON encoder: fewer tokens than JSON
|
|
618
|
+
- **Method level** - `-m` adds every method with its line number and token count
|
|
619
|
+
- **Cross-platform clipboard** - Works on macOS, Linux, and Windows, and falls back to a file
|
|
379
620
|
|
|
380
621
|
### Usage
|
|
381
622
|
|
|
@@ -386,16 +627,14 @@ ctxman --context-export
|
|
|
386
627
|
# Copy minimal context directly to clipboard (2.3k chars JSON - identical to file)
|
|
387
628
|
ctxman --context-clipboard
|
|
388
629
|
|
|
389
|
-
# Copy detailed context to clipboard (8.6k chars)
|
|
390
|
-
ctxman --detailed-context --context-clipboard
|
|
391
|
-
|
|
392
630
|
# Combine with regular analysis
|
|
393
631
|
ctxman --save-report --context-clipboard
|
|
394
632
|
```
|
|
395
633
|
|
|
396
634
|
### Output Format Examples
|
|
397
635
|
|
|
398
|
-
**
|
|
636
|
+
**JSON (default):**
|
|
637
|
+
|
|
399
638
|
```json
|
|
400
639
|
{
|
|
401
640
|
"project": {
|
|
@@ -404,54 +643,26 @@ ctxman --save-report --context-clipboard
|
|
|
404
643
|
"totalTokens": 181480
|
|
405
644
|
},
|
|
406
645
|
"paths": {
|
|
407
|
-
"utility-mcp/src/server/": [
|
|
408
|
-
"CloudStackUtilityMCP.js"
|
|
409
|
-
],
|
|
646
|
+
"utility-mcp/src/server/": ["CloudStackUtilityMCP.js"],
|
|
410
647
|
"utility-mcp/src/handlers/": [
|
|
411
648
|
"workflow-handlers.js",
|
|
412
649
|
"tool-handlers.js",
|
|
413
650
|
"analytics-handler.js"
|
|
414
651
|
],
|
|
415
|
-
"utility-mcp/src/utils/": [
|
|
416
|
-
"security.js",
|
|
417
|
-
"usage-tracker.js",
|
|
418
|
-
"cache-warming.js"
|
|
419
|
-
]
|
|
652
|
+
"utility-mcp/src/utils/": ["security.js", "usage-tracker.js", "cache-warming.js"]
|
|
420
653
|
}
|
|
421
654
|
}
|
|
422
655
|
```
|
|
423
656
|
|
|
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
657
|
**Use Cases**
|
|
441
658
|
|
|
442
|
-
**Compact Format (2.3k chars JSON):**
|
|
443
659
|
1. **LLM Integration** - Structured data for AI assistants with complete project context
|
|
444
|
-
2. **Programmatic Processing** - JSON format for automated tools and scripts
|
|
660
|
+
2. **Programmatic Processing** - JSON format for automated tools and scripts
|
|
445
661
|
3. **Context Sharing** - Identical format in clipboard and file exports
|
|
446
662
|
4. **Development Workflows** - Consistent structure for CI/CD and automation
|
|
447
663
|
|
|
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
664
|
**General Use Cases:**
|
|
665
|
+
|
|
455
666
|
- Development workflow integration
|
|
456
667
|
- CI/CD pipeline context generation
|
|
457
668
|
- Automated documentation updates
|
|
@@ -464,6 +675,7 @@ Context-manager now supports generating GitIngest-style digest files - a single,
|
|
|
464
675
|
### What is GitIngest Format?
|
|
465
676
|
|
|
466
677
|
GitIngest format consolidates your entire codebase into a single text file with:
|
|
678
|
+
|
|
467
679
|
- Project summary and statistics
|
|
468
680
|
- Visual directory tree structure
|
|
469
681
|
- Complete file contents with clear separators
|
|
@@ -495,6 +707,7 @@ ctxman --gitingest-from-context my-context.json
|
|
|
495
707
|
```
|
|
496
708
|
|
|
497
709
|
**Why use JSON-based digest?**
|
|
710
|
+
|
|
498
711
|
- ⚡ **Performance**: Instant digest generation without re-scanning
|
|
499
712
|
- 🔄 **Reusability**: Generate multiple digests from one analysis
|
|
500
713
|
- 📦 **Workflow**: Separate analysis from export steps
|
|
@@ -535,6 +748,9 @@ FILE: src/utils.js
|
|
|
535
748
|
- **Token Estimates**: Formatted as "1.2k" or "1.5M"
|
|
536
749
|
- **Sorted Output**: Files sorted by token count (largest first)
|
|
537
750
|
- **Filter Compatible**: Respects all `.gitignore` and context ignore rules
|
|
751
|
+
- **Secret Redaction**: Known credential formats (AWS access key IDs, GitHub/GitLab/npm/Slack
|
|
752
|
+
tokens, Stripe live keys, Google/OpenAI/Anthropic API keys, PEM private keys) are replaced
|
|
753
|
+
with `[REDACTED:<type>]` and counted in the console output. Pass `--no-redact` to keep them.
|
|
538
754
|
|
|
539
755
|
### Use Cases
|
|
540
756
|
|
|
@@ -591,6 +807,7 @@ utility-mcp/src/**/*.js
|
|
|
591
807
|
### Creating Custom Configurations
|
|
592
808
|
|
|
593
809
|
**For EXCLUDE mode** (edit `.contextignore`):
|
|
810
|
+
|
|
594
811
|
```bash
|
|
595
812
|
# Remove lines to include more file types
|
|
596
813
|
# Add patterns to exclude specific files
|
|
@@ -604,6 +821,7 @@ specific-directory/**
|
|
|
604
821
|
```
|
|
605
822
|
|
|
606
823
|
**For INCLUDE mode** (create `.contextinclude`):
|
|
824
|
+
|
|
607
825
|
```bash
|
|
608
826
|
# Include specific files or patterns
|
|
609
827
|
src/**/*.js # All JS files in src
|
|
@@ -625,14 +843,17 @@ src/**/*.js
|
|
|
625
843
|
|
|
626
844
|
## Installation
|
|
627
845
|
|
|
628
|
-
|
|
846
|
+
tiktoken is a dependency of ctxman, so token counting works out of the box (exact for OpenAI
|
|
847
|
+
models, approximate for other vendors; see [Token counts per model](#token-counts-per-model)). If
|
|
848
|
+
tiktoken cannot be loaded, the tool falls back to smart estimation (~95% accuracy).
|
|
849
|
+
|
|
850
|
+
For exact Claude counts with `ctxman count --api`, install Anthropic's SDK and set your API key:
|
|
629
851
|
|
|
630
852
|
```bash
|
|
631
|
-
npm install
|
|
853
|
+
npm install -g @anthropic-ai/sdk # next to a global ctxman; without -g for a project install
|
|
854
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
632
855
|
```
|
|
633
856
|
|
|
634
|
-
Without tiktoken, the tool uses smart estimation (~95% accuracy).
|
|
635
|
-
|
|
636
857
|
## Output Example
|
|
637
858
|
|
|
638
859
|
```
|
|
@@ -664,17 +885,18 @@ Extension Files Tokens Size (KB) Lines
|
|
|
664
885
|
## Context Management
|
|
665
886
|
|
|
666
887
|
Perfect for LLM context window optimization:
|
|
888
|
+
|
|
667
889
|
- **181k tokens** = Core application logic only
|
|
668
890
|
- **Clean analysis** = No noise from docs, configs, or build files
|
|
669
891
|
- **Focused development** = Essential code for AI-assisted development
|
|
670
892
|
- **Context efficiency** = Maximum useful code per token
|
|
671
893
|
- **Dual mode flexibility** = Precise include/exclude control
|
|
672
|
-
- **
|
|
673
|
-
- **Detailed export** = 8.6k chars for comprehensive analysis when needed
|
|
894
|
+
- **Compact export** = Paths grouped by directory, in JSON or TOON, for frequent AI interactions
|
|
674
895
|
|
|
675
896
|
## Integration
|
|
676
897
|
|
|
677
898
|
You can integrate this tool into:
|
|
899
|
+
|
|
678
900
|
- CI/CD pipelines for code size monitoring
|
|
679
901
|
- Pre-commit hooks for token budget checks
|
|
680
902
|
- Documentation generation workflows
|
|
@@ -685,22 +907,26 @@ You can integrate this tool into:
|
|
|
685
907
|
## Troubleshooting
|
|
686
908
|
|
|
687
909
|
### Include vs Exclude Mode Issues
|
|
910
|
+
|
|
688
911
|
- **INCLUDE mode active**: Remove `.contextinclude` to use EXCLUDE mode
|
|
689
912
|
- **Wrong files included**: Check if `.contextinclude` exists (takes priority)
|
|
690
913
|
- **Mode confusion**: Use verbose mode to see which mode is active
|
|
691
914
|
|
|
692
915
|
### Patterns Not Working
|
|
916
|
+
|
|
693
917
|
- Ensure no inline comments in ignore/include pattern files
|
|
694
918
|
- Use file patterns (`docs/**`) instead of directory patterns (`docs/`)
|
|
695
919
|
- Test specific patterns with verbose mode
|
|
696
920
|
- Check pattern syntax: `**` for recursive, `*` for single level
|
|
697
921
|
|
|
698
922
|
### Token Count Issues
|
|
923
|
+
|
|
699
924
|
- **Too high**: Review included files with verbose mode, add exclusion patterns
|
|
700
925
|
- **Too low**: Check if important files are excluded, review patterns
|
|
701
926
|
- **Inconsistent**: Verify which mode is active (include vs exclude)
|
|
702
927
|
|
|
703
928
|
### Missing Expected Files
|
|
929
|
+
|
|
704
930
|
- Check if files are excluded by `.gitignore` (always respected)
|
|
705
931
|
- Verify calculator ignore/include patterns
|
|
706
932
|
- Ensure files are recognized as text files
|
|
@@ -710,7 +936,7 @@ You can integrate this tool into:
|
|
|
710
936
|
|
|
711
937
|
LLM context manager with method-level filtering and token optimization. The ultimate tool for AI-assisted development.
|
|
712
938
|
|
|
713
|
-
|
|
939
|
+
_Created by Hakkı Sağdıç_
|
|
714
940
|
|
|
715
941
|
## 🚀 Features
|
|
716
942
|
|
|
@@ -718,15 +944,16 @@ LLM context manager with method-level filtering and token optimization. The ulti
|
|
|
718
944
|
🔧 **Method-level analysis** - Extract and analyze specific methods from JavaScript/TypeScript/Rust/C#/Go/Java
|
|
719
945
|
📋 **Dual filtering system** - Include/exclude files and methods with pattern matching
|
|
720
946
|
📊 **LLM context optimization** - Generate ultra-compact context for AI assistants
|
|
721
|
-
🎯 **
|
|
947
|
+
🎯 **Token counting** - tiktoken with the target model's encoding (exact for OpenAI models)
|
|
722
948
|
📤 **Multiple export formats** - JSON reports, clipboard, file exports
|
|
723
949
|
📦 **NPM package** - Use programmatically or as global CLI tool
|
|
724
950
|
🔍 **Pattern matching** - Wildcards and regex support for flexible filtering
|
|
725
|
-
⚡ **Performance optimized** - 36% smaller codebase with enhanced functionality
|
|
951
|
+
⚡ **Performance optimized** - 36% smaller codebase with enhanced functionality
|
|
726
952
|
|
|
727
953
|
## 📦 Installation
|
|
728
954
|
|
|
729
955
|
### Option 1: NPM Package (Recommended)
|
|
956
|
+
|
|
730
957
|
```bash
|
|
731
958
|
# Local installation
|
|
732
959
|
npm install ctxman
|
|
@@ -739,6 +966,7 @@ ctxman --help
|
|
|
739
966
|
```
|
|
740
967
|
|
|
741
968
|
### Option 2: Direct Usage
|
|
969
|
+
|
|
742
970
|
```bash
|
|
743
971
|
# Clone and use directly
|
|
744
972
|
git clone <repository>
|
|
@@ -749,6 +977,7 @@ node token-calculator.js --help
|
|
|
749
977
|
## 🎯 Quick Start
|
|
750
978
|
|
|
751
979
|
### Basic Analysis
|
|
980
|
+
|
|
752
981
|
```bash
|
|
753
982
|
# Interactive analysis with export selection
|
|
754
983
|
ctxman
|
|
@@ -764,6 +993,7 @@ ctxman --method-level --save-report --verbose
|
|
|
764
993
|
```
|
|
765
994
|
|
|
766
995
|
### Advanced Usage
|
|
996
|
+
|
|
767
997
|
```bash
|
|
768
998
|
# Focus on specific methods only
|
|
769
999
|
echo "calculateTokens\nhandleRequest\n*Validator" > .methodinclude
|
|
@@ -802,14 +1032,14 @@ const { TokenAnalyzer } = require('ctxman');
|
|
|
802
1032
|
|
|
803
1033
|
// Basic file-level analysis
|
|
804
1034
|
const analyzer = new TokenAnalyzer('./src', {
|
|
805
|
-
|
|
806
|
-
|
|
1035
|
+
methodLevel: false,
|
|
1036
|
+
verbose: true,
|
|
807
1037
|
});
|
|
808
1038
|
|
|
809
1039
|
// Method-level analysis
|
|
810
1040
|
const methodAnalyzer = new TokenAnalyzer('./src', {
|
|
811
|
-
|
|
812
|
-
|
|
1041
|
+
methodLevel: true,
|
|
1042
|
+
saveReport: true,
|
|
813
1043
|
});
|
|
814
1044
|
|
|
815
1045
|
analyzer.run();
|
|
@@ -820,11 +1050,13 @@ analyzer.run();
|
|
|
820
1050
|
### File-Level Filtering
|
|
821
1051
|
|
|
822
1052
|
**Priority Order:**
|
|
1053
|
+
|
|
823
1054
|
1. `.gitignore` (project root) - Standard git exclusions (always respected)
|
|
824
1055
|
2. `.contextinclude` - INCLUDE mode (highest priority for files)
|
|
825
1056
|
3. `.contextignore` - EXCLUDE mode (fallback for files)
|
|
826
1057
|
|
|
827
1058
|
**`.contextinclude`** - Include only these files:
|
|
1059
|
+
|
|
828
1060
|
```bash
|
|
829
1061
|
# Include only core JavaScript files
|
|
830
1062
|
utility-mcp/src/**/*.js
|
|
@@ -832,7 +1064,8 @@ utility-mcp/src/**/*.js
|
|
|
832
1064
|
!utility-mcp/src/workflows/**
|
|
833
1065
|
```
|
|
834
1066
|
|
|
835
|
-
**`.contextignore`** - Exclude these files:
|
|
1067
|
+
**`.contextignore`** - Exclude these files:
|
|
1068
|
+
|
|
836
1069
|
```bash
|
|
837
1070
|
# Exclude documentation and config
|
|
838
1071
|
**/*.md
|
|
@@ -846,6 +1079,7 @@ test/
|
|
|
846
1079
|
### Method-Level Filtering
|
|
847
1080
|
|
|
848
1081
|
**`.methodinclude`** - Include only these methods:
|
|
1082
|
+
|
|
849
1083
|
```bash
|
|
850
1084
|
# Core business logic methods
|
|
851
1085
|
calculateTokens
|
|
@@ -863,6 +1097,7 @@ TokenCalculator.* # All methods in TokenCalculator class
|
|
|
863
1097
|
```
|
|
864
1098
|
|
|
865
1099
|
**`.methodignore`** - Exclude these methods:
|
|
1100
|
+
|
|
866
1101
|
```bash
|
|
867
1102
|
# Utility and debug methods
|
|
868
1103
|
console
|
|
@@ -879,17 +1114,18 @@ utils.debugLog
|
|
|
879
1114
|
|
|
880
1115
|
### Pattern Syntax
|
|
881
1116
|
|
|
882
|
-
| Pattern
|
|
883
|
-
|
|
884
|
-
| `methodName`
|
|
885
|
-
| `*pattern*`
|
|
886
|
-
| `Class.*`
|
|
887
|
-
| `file.method` | Specific file method | `server.handleRequest`
|
|
888
|
-
| `!pattern`
|
|
1117
|
+
| Pattern | Description | Example |
|
|
1118
|
+
| ------------- | -------------------- | ----------------------------------- |
|
|
1119
|
+
| `methodName` | Exact match | `calculateTokens` |
|
|
1120
|
+
| `*pattern*` | Contains pattern | `*Handler` matches `requestHandler` |
|
|
1121
|
+
| `Class.*` | All methods in class | `TokenCalculator.*` |
|
|
1122
|
+
| `file.method` | Specific file method | `server.handleRequest` |
|
|
1123
|
+
| `!pattern` | Negation (exclude) | `!*test*` |
|
|
889
1124
|
|
|
890
1125
|
## 📤 Output Formats
|
|
891
1126
|
|
|
892
1127
|
### 1. File-Level Context (Default)
|
|
1128
|
+
|
|
893
1129
|
**Use case:** General codebase analysis, file organization
|
|
894
1130
|
|
|
895
1131
|
```json
|
|
@@ -907,6 +1143,7 @@ utils.debugLog
|
|
|
907
1143
|
```
|
|
908
1144
|
|
|
909
1145
|
### 2. Method-Level Context (`--method-level`)
|
|
1146
|
+
|
|
910
1147
|
**Use case:** Focused analysis, debugging specific methods, LLM context optimization
|
|
911
1148
|
|
|
912
1149
|
```json
|
|
@@ -918,12 +1155,10 @@ utils.debugLog
|
|
|
918
1155
|
},
|
|
919
1156
|
"methods": {
|
|
920
1157
|
"src/server.js": [
|
|
921
|
-
{"name": "handleRequest", "line": 15, "tokens": 234},
|
|
922
|
-
{"name": "validateInput", "line": 45, "tokens": 156}
|
|
1158
|
+
{ "name": "handleRequest", "line": 15, "tokens": 234 },
|
|
1159
|
+
{ "name": "validateInput", "line": 45, "tokens": 156 }
|
|
923
1160
|
],
|
|
924
|
-
"src/utils.js": [
|
|
925
|
-
{"name": "processData", "line": 12, "tokens": 89}
|
|
926
|
-
]
|
|
1161
|
+
"src/utils.js": [{ "name": "processData", "line": 12, "tokens": 89 }]
|
|
927
1162
|
},
|
|
928
1163
|
"methodStats": {
|
|
929
1164
|
"totalMethods": 150,
|
|
@@ -934,6 +1169,7 @@ utils.debugLog
|
|
|
934
1169
|
```
|
|
935
1170
|
|
|
936
1171
|
### 3. Detailed Report (JSON)
|
|
1172
|
+
|
|
937
1173
|
**Use case:** Comprehensive analysis, CI/CD integration, historical tracking
|
|
938
1174
|
|
|
939
1175
|
```json
|
|
@@ -956,18 +1192,19 @@ utils.debugLog
|
|
|
956
1192
|
|
|
957
1193
|
## CLI Options
|
|
958
1194
|
|
|
959
|
-
| Option
|
|
960
|
-
|
|
961
|
-
| `--save-report`
|
|
962
|
-
| `--verbose`
|
|
963
|
-
| `--context-export`
|
|
964
|
-
| `--context-clipboard` |
|
|
965
|
-
| `--method-level`
|
|
966
|
-
| `--help`
|
|
1195
|
+
| Option | Short | Description |
|
|
1196
|
+
| --------------------- | ----- | ----------------------------------- |
|
|
1197
|
+
| `--save-report` | `-s` | Save detailed JSON report |
|
|
1198
|
+
| `--verbose` | `-v` | Show included files and directories |
|
|
1199
|
+
| `--context-export` | | Generate LLM context file |
|
|
1200
|
+
| `--context-clipboard` | | Copy context to clipboard |
|
|
1201
|
+
| `--method-level` | `-m` | Enable method-level analysis |
|
|
1202
|
+
| `--help` | `-h` | Show help message |
|
|
967
1203
|
|
|
968
1204
|
## 📊 Use Cases & Examples
|
|
969
1205
|
|
|
970
1206
|
### 1. 🤖 LLM Context Optimization
|
|
1207
|
+
|
|
971
1208
|
**Goal:** Generate minimal context for AI assistants
|
|
972
1209
|
|
|
973
1210
|
```bash
|
|
@@ -981,7 +1218,8 @@ ctxman --method-level --context-export
|
|
|
981
1218
|
|
|
982
1219
|
**Result:** 89% smaller context compared to full codebase
|
|
983
1220
|
|
|
984
|
-
### 2. 📊 Codebase Analysis
|
|
1221
|
+
### 2. 📊 Codebase Analysis
|
|
1222
|
+
|
|
985
1223
|
**Goal:** Understand project complexity and structure
|
|
986
1224
|
|
|
987
1225
|
```bash
|
|
@@ -993,6 +1231,7 @@ ctxman --method-level --save-report
|
|
|
993
1231
|
```
|
|
994
1232
|
|
|
995
1233
|
### 3. 🔍 Method-Level Debugging
|
|
1234
|
+
|
|
996
1235
|
**Goal:** Focus on specific problematic methods
|
|
997
1236
|
|
|
998
1237
|
```bash
|
|
@@ -1006,6 +1245,7 @@ ctxman --method-level
|
|
|
1006
1245
|
```
|
|
1007
1246
|
|
|
1008
1247
|
### 4. 🚀 CI/CD Integration
|
|
1248
|
+
|
|
1009
1249
|
**Goal:** Monitor codebase growth and complexity
|
|
1010
1250
|
|
|
1011
1251
|
```bash
|
|
@@ -1017,6 +1257,7 @@ ctxman --method-level --save-report
|
|
|
1017
1257
|
```
|
|
1018
1258
|
|
|
1019
1259
|
### 5. 📈 Code Quality Gates
|
|
1260
|
+
|
|
1020
1261
|
**Goal:** Ensure code stays within token budgets
|
|
1021
1262
|
|
|
1022
1263
|
```bash
|
|
@@ -1032,14 +1273,14 @@ fi
|
|
|
1032
1273
|
|
|
1033
1274
|
### Core Options
|
|
1034
1275
|
|
|
1035
|
-
| Option
|
|
1036
|
-
|
|
1037
|
-
| `--save-report`
|
|
1038
|
-
| `--verbose`
|
|
1039
|
-
| `--context-export`
|
|
1040
|
-
| `--context-clipboard` |
|
|
1041
|
-
| `--method-level`
|
|
1042
|
-
| `--help`
|
|
1276
|
+
| Option | Short | Description | Example |
|
|
1277
|
+
| --------------------- | ----- | ---------------------------- | ---------------------------- |
|
|
1278
|
+
| `--save-report` | `-s` | Save detailed JSON report | `ctxman -s` |
|
|
1279
|
+
| `--verbose` | `-v` | Show included files/methods | `ctxman -v` |
|
|
1280
|
+
| `--context-export` | | Generate LLM context file | `ctxman --context-export` |
|
|
1281
|
+
| `--context-clipboard` | | Copy context to clipboard | `ctxman --context-clipboard` |
|
|
1282
|
+
| `--method-level` | `-m` | Enable method-level analysis | `ctxman -m` |
|
|
1283
|
+
| `--help` | `-h` | Show help message | `ctxman -h` |
|
|
1043
1284
|
|
|
1044
1285
|
### Usage Patterns
|
|
1045
1286
|
|
|
@@ -1058,6 +1299,9 @@ ctxman --save-report --context-export
|
|
|
1058
1299
|
|
|
1059
1300
|
# Development debugging
|
|
1060
1301
|
ctxman --method-level --verbose
|
|
1302
|
+
|
|
1303
|
+
# Token count for one model (exact for Claude with --api)
|
|
1304
|
+
ctxman count --model claude-sonnet-5-5 --api
|
|
1061
1305
|
```
|
|
1062
1306
|
|
|
1063
1307
|
## 💻 Programmatic API
|
|
@@ -1070,7 +1314,7 @@ const { TokenAnalyzer } = require('ctxman');
|
|
|
1070
1314
|
// File-level analysis
|
|
1071
1315
|
const analyzer = new TokenAnalyzer('./src', {
|
|
1072
1316
|
verbose: true,
|
|
1073
|
-
saveReport: true
|
|
1317
|
+
saveReport: true,
|
|
1074
1318
|
});
|
|
1075
1319
|
|
|
1076
1320
|
analyzer.run();
|
|
@@ -1085,7 +1329,7 @@ const { TokenAnalyzer, MethodAnalyzer } = require('ctxman');
|
|
|
1085
1329
|
const analyzer = new TokenAnalyzer('./src', {
|
|
1086
1330
|
methodLevel: true,
|
|
1087
1331
|
contextExport: true,
|
|
1088
|
-
verbose: false
|
|
1332
|
+
verbose: false,
|
|
1089
1333
|
});
|
|
1090
1334
|
|
|
1091
1335
|
analyzer.run();
|
|
@@ -1101,17 +1345,17 @@ const methods = methodAnalyzer.extractMethods(fileContent, 'server.js');
|
|
|
1101
1345
|
const analyzer = new TokenAnalyzer('./src', {
|
|
1102
1346
|
// Enable method-level analysis
|
|
1103
1347
|
methodLevel: true,
|
|
1104
|
-
|
|
1348
|
+
|
|
1105
1349
|
// Output options
|
|
1106
1350
|
saveReport: true,
|
|
1107
1351
|
contextExport: true,
|
|
1108
1352
|
contextToClipboard: true,
|
|
1109
|
-
|
|
1353
|
+
|
|
1110
1354
|
// Verbosity
|
|
1111
1355
|
verbose: true,
|
|
1112
|
-
|
|
1356
|
+
|
|
1113
1357
|
// Compact context (for LLM optimization)
|
|
1114
|
-
compactContext: true
|
|
1358
|
+
compactContext: true,
|
|
1115
1359
|
});
|
|
1116
1360
|
|
|
1117
1361
|
// Access results
|
|
@@ -1125,29 +1369,30 @@ console.log('Analysis complete!');
|
|
|
1125
1369
|
const { MethodAnalyzer, MethodFilterParser } = require('ctxman');
|
|
1126
1370
|
|
|
1127
1371
|
// Create custom method filter
|
|
1128
|
-
const filter = new MethodFilterParser(
|
|
1129
|
-
'./custom-methods.include',
|
|
1130
|
-
'./custom-methods.ignore'
|
|
1131
|
-
);
|
|
1372
|
+
const filter = new MethodFilterParser('./custom-methods.include', './custom-methods.ignore');
|
|
1132
1373
|
|
|
1133
1374
|
// Analyze specific file
|
|
1134
1375
|
const methodAnalyzer = new MethodAnalyzer();
|
|
1135
1376
|
const methods = methodAnalyzer.extractMethods(content, filePath);
|
|
1136
1377
|
|
|
1137
1378
|
// Filter methods
|
|
1138
|
-
const filteredMethods = methods.filter(method =>
|
|
1379
|
+
const filteredMethods = methods.filter((method) =>
|
|
1139
1380
|
filter.shouldIncludeMethod(method.name, fileName)
|
|
1140
1381
|
);
|
|
1141
1382
|
```
|
|
1142
1383
|
|
|
1143
1384
|
## Requirements
|
|
1144
1385
|
|
|
1145
|
-
- **Node.js**:
|
|
1146
|
-
- **tiktoken**: ^1.0.
|
|
1386
|
+
- **Node.js**: 22 or newer (tested on 22 LTS and 24 LTS)
|
|
1387
|
+
- **tiktoken**: ^1.0.22 (installed with ctxman; token counting)
|
|
1388
|
+
- **@anthropic-ai/sdk** (optional, install it yourself; used only by `ctxman count --api`)
|
|
1389
|
+
- **@xenova/transformers** and **@lancedb/lancedb** (optional dependencies, used only by
|
|
1390
|
+
`ctxman ask` for local semantic search). npm installs them by default; skip them with
|
|
1391
|
+
`npm install -g ctxman --omit=optional` if you do not need `ask`.
|
|
1147
1392
|
|
|
1148
1393
|
## License
|
|
1149
1394
|
|
|
1150
|
-
MIT License - see LICENSE
|
|
1395
|
+
MIT License - see [LICENSE](LICENSE) for details
|
|
1151
1396
|
|
|
1152
1397
|
## Contributing
|
|
1153
1398
|
|
|
@@ -1164,4 +1409,4 @@ MIT License - see LICENSE file for details
|
|
|
1164
1409
|
|
|
1165
1410
|
---
|
|
1166
1411
|
|
|
1167
|
-
|
|
1412
|
+
_Created with ❤️ by Hakkı Sağdıç_
|