@ctxo/cli 0.0.1 → 0.7.0-alpha.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/llms-full.txt ADDED
@@ -0,0 +1,284 @@
1
+ # Ctxo MCP Server — Full Reference
2
+
3
+ > AI agents don't fail because they can't code. They fail because they code blind. Ctxo gives them the full picture before they write a single line.
4
+ > npm: @ctxo/cli (v0.7.0-alpha.0) | GitHub: https://github.com/alperhankendi/Ctxo
5
+
6
+ ## Setup
7
+
8
+ ```bash
9
+ npx @ctxo/cli init # Detect languages + install plugins + wire MCP
10
+ npx @ctxo/cli index # Build codebase index (required once)
11
+ npx @ctxo/cli index --check # CI gate: fail if index stale
12
+ npx @ctxo/cli # Start MCP server (stdio transport)
13
+ ```
14
+
15
+ MCP client configuration:
16
+ ```json
17
+ { "mcpServers": { "ctxo": { "command": "npx", "args": ["-y", "@ctxo/cli"] } } }
18
+ ```
19
+
20
+ ---
21
+
22
+ ## Monorepo & Plugin Architecture (v0.7+)
23
+
24
+ Ctxo is a pnpm workspace monorepo with five packages:
25
+
26
+ - `@ctxo/cli` (packages/cli) — CLI entry, composition root, MCP server, tool handlers
27
+ - `@ctxo/plugin-api` (packages/plugin-api) — `CtxoLanguagePlugin` v1 protocol interface
28
+ - `@ctxo/lang-typescript` — ts-morph (full tier) plugin for TS/JS
29
+ - `@ctxo/lang-go` — tree-sitter / gopls plugin for Go
30
+ - `@ctxo/lang-csharp` — Roslyn plugin for C#
31
+
32
+ Plugin protocol v1 (`CtxoLanguagePlugin`):
33
+ - `apiVersion: 1`
34
+ - `id`: unique plugin identifier
35
+ - `extensions`: file extensions handled (e.g. `['.ts', '.tsx']`)
36
+ - `tier`: `'syntax'` | `'full'`
37
+ - `createAdapter(ctx)`: factory returning an `ILanguageAdapter` instance
38
+
39
+ Discovery: at startup Ctxo scans the project's `package.json` dependencies for names matching `@ctxo/lang-*` or `ctxo-lang-*` and registers them. `ctxo install` adds plugins; `ctxo index --install-missing` auto-installs plugins required by detected languages. New CLI: `ctxo doctor --fix`, `ctxo version`, and `ctxo --version --verbose|--json` for plugin/runtime diagnostics.
40
+
41
+ Source paths referenced below live under `packages/cli/src/`.
42
+
43
+ ---
44
+
45
+ ## Tool Reference (14 tools)
46
+
47
+ ### get_logic_slice
48
+ Retrieve a symbol and all its transitive dependencies.
49
+
50
+ Parameters:
51
+ - symbolId (string, optional): Symbol ID (format: file::name::kind)
52
+ - symbolIds (string[], optional): Batch: array of symbol IDs
53
+ - level (number 1-4, default 3): L1=signature, L2=direct deps, L3=full closure, L4=with token budget
54
+ - intent (string, optional): Filter dependencies by keyword
55
+
56
+ When to use: Understanding what a symbol depends on (downstream view).
57
+ Instead of: get_blast_radius (upstream/impact), get_context_for_task (task-specific).
58
+
59
+ ### get_blast_radius
60
+ Find all symbols that would break if a target changes.
61
+
62
+ Parameters:
63
+ - symbolId (string, required): Symbol ID
64
+ - confidence (enum: confirmed|likely|potential, optional): Filter by tier
65
+ - intent (string, optional): Filter by keyword
66
+
67
+ Returns: impactedSymbols array with symbolId, depth, riskScore, confidence, edgeKinds.
68
+ 3-tier model: confirmed (calls/extends/implements), likely (uses/co-changed), potential (imports-only).
69
+
70
+ When to use: BEFORE modifying any function or class.
71
+ Instead of: get_logic_slice (forward deps), get_pr_impact (PR-level).
72
+
73
+ ### get_architectural_overlay
74
+ Get project architectural layer map.
75
+
76
+ Parameters:
77
+ - layer (string, optional): Filter by layer name
78
+
79
+ Returns: Symbols grouped into Domain, Infrastructure, Adapter, Test, Composition, Configuration layers.
80
+
81
+ When to use: Onboarding to a new codebase, validating layer boundaries.
82
+
83
+ ### get_why_context
84
+ Retrieve git commit history and anti-pattern warnings for a symbol.
85
+
86
+ Parameters:
87
+ - symbolId (string, required): Symbol ID
88
+ - maxCommits (number, optional): Limit to N most recent commits
89
+
90
+ Returns: commitHistory array + antiPatternWarnings (reverts, rollbacks, undo patterns).
91
+
92
+ When to use: Understanding WHY code was written this way, checking for problem history.
93
+ Pair with: get_change_intelligence (complexity/churn scores).
94
+
95
+ ### get_change_intelligence
96
+ Retrieve complexity x churn composite score.
97
+
98
+ Parameters:
99
+ - symbolId (string, required): Symbol ID
100
+
101
+ Returns: complexity (0-1), churn (0-1), composite (0-1), band (low|medium|high|critical).
102
+
103
+ When to use: Identifying refactoring targets, assessing modification risk.
104
+
105
+ ### find_dead_code
106
+ Find unreachable symbols and files.
107
+
108
+ Parameters:
109
+ - includeTests (boolean, default false): Include test files
110
+ - intent (string, optional): Filter results by keyword
111
+
112
+ Returns: deadSymbols (with confidence 1.0/0.9/0.7 and reason), deadFiles, unusedExports, scaffolding markers.
113
+
114
+ When to use: Cleanup, refactoring, confirming code is truly unused.
115
+ Instead of: find_importers (specific symbol reverse lookup).
116
+
117
+ ### get_context_for_task
118
+ Get task-optimized context for a symbol.
119
+
120
+ Parameters:
121
+ - symbolId (string, required): Symbol ID
122
+ - taskType (enum: fix|extend|refactor|understand, required): Determines context mix
123
+ - tokenBudget (number, default 4000): Max tokens
124
+
125
+ Task types:
126
+ - fix: History + anti-patterns + direct deps (bug investigation)
127
+ - extend: Deps + blast radius + interfaces (adding features)
128
+ - refactor: Importers + complexity + churn (restructuring)
129
+ - understand: Full slice + architecture (learning)
130
+
131
+ When to use: BEST starting point when you know the symbol AND your intent.
132
+
133
+ ### get_ranked_context
134
+ Search and rank symbols by relevance to a query.
135
+
136
+ Parameters:
137
+ - query (string, required): Natural language search query
138
+ - tokenBudget (number, default 4000): Max tokens for results
139
+ - strategy (enum: combined|dependency|importance, default combined): Ranking strategy
140
+
141
+ Returns: Symbols ranked by BM25 relevance + PageRank importance, packed within budget.
142
+
143
+ When to use: Have a question/topic but don't know which symbol to look at.
144
+ Instead of: search_symbols (exact name/regex search).
145
+
146
+ ### search_symbols
147
+ Search symbols by name or regex pattern.
148
+
149
+ Parameters:
150
+ - pattern (string, required): Substring or regex pattern
151
+ - kind (enum: function|class|interface|method|variable|type, optional): Filter by kind
152
+ - filePattern (string, optional): Filter by file path substring
153
+ - limit (number 1-100, default 25): Max results
154
+
155
+ When to use: Know (part of) the symbol name, need its ID for other tools.
156
+ Instead of: get_ranked_context (semantic/relevance search).
157
+
158
+ ### get_changed_symbols
159
+ Get symbols in recently changed files.
160
+
161
+ Parameters:
162
+ - since (string, default HEAD~1): Git ref to diff against
163
+ - maxFiles (number, default 50): Max files to process
164
+
165
+ When to use: See what was modified in recent commits.
166
+ Instead of: get_pr_impact (full PR risk assessment).
167
+
168
+ ### find_importers
169
+ Find all symbols that depend on a given symbol (reverse dependency).
170
+
171
+ Parameters:
172
+ - symbolId (string, required): Symbol ID
173
+ - edgeKinds (string[], optional): Filter by imports|calls|extends|implements|uses
174
+ - transitive (boolean, default false): Follow transitive reverse edges
175
+ - maxDepth (number 1-10, default 5): Max BFS depth
176
+ - intent (string, optional): Filter by keyword
177
+
178
+ When to use: Check if safe to modify/delete, find all consumers.
179
+ Instead of: get_blast_radius (aggregated impact with risk scores).
180
+
181
+ ### get_class_hierarchy
182
+ Get class inheritance hierarchy.
183
+
184
+ Parameters:
185
+ - symbolId (string, optional): Root symbol (omit for full project)
186
+ - direction (enum: ancestors|descendants|both, default both): Traversal direction
187
+
188
+ When to use: OOP code, understanding type relationships before modifying base class/interface.
189
+
190
+ ### get_symbol_importance
191
+ Rank symbols by PageRank centrality.
192
+
193
+ Parameters:
194
+ - limit (number 1-200, default 25): Max results
195
+ - kind (enum: function|class|interface|method|variable|type, optional): Filter
196
+ - filePattern (string, optional): Filter by file path
197
+ - damping (number 0-1, default 0.85): PageRank damping factor
198
+
199
+ When to use: Identify most critical symbols, high-risk modification targets.
200
+ Instead of: find_dead_code (unused/unimportant code).
201
+
202
+ ### get_pr_impact
203
+ Analyze PR impact in a single call.
204
+
205
+ Parameters:
206
+ - since (string, default HEAD~1): Git ref to diff against
207
+ - maxFiles (number, default 50): Max files
208
+ - confidence (enum: confirmed|likely|potential, optional): Filter tier
209
+
210
+ Returns: changedFiles, changedSymbols, totalImpact, riskLevel (low|medium|high), per-file blast radius, co-change data.
211
+
212
+ When to use: FIRST tool when reviewing a PR or evaluating recent commits.
213
+
214
+ ---
215
+
216
+ ## Tool Selection Guide
217
+
218
+ ```
219
+ Reviewing a PR or recent changes?
220
+ -> get_pr_impact (single call, full risk assessment)
221
+
222
+ About to modify a function or class?
223
+ -> get_blast_radius (what breaks if I change this?)
224
+ -> then get_why_context (any history of problems?)
225
+
226
+ Need to understand what a symbol does?
227
+ -> get_context_for_task(taskType: "understand")
228
+ -> or get_logic_slice (L2 for overview, L3 for full closure)
229
+
230
+ Fixing a bug?
231
+ -> get_context_for_task(taskType: "fix")
232
+
233
+ Adding a feature / extending code?
234
+ -> get_context_for_task(taskType: "extend")
235
+
236
+ Refactoring?
237
+ -> get_context_for_task(taskType: "refactor")
238
+
239
+ Don't know the symbol name?
240
+ -> search_symbols (by name/regex)
241
+ -> get_ranked_context (by natural language query)
242
+
243
+ Onboarding to a new codebase?
244
+ -> get_architectural_overlay (layer map)
245
+ -> get_symbol_importance (most critical symbols)
246
+
247
+ Cleaning up code?
248
+ -> find_dead_code (unused symbols)
249
+ -> get_change_intelligence (complexity hotspots)
250
+
251
+ Checking if safe to delete/rename?
252
+ -> find_importers (who depends on this?)
253
+ -> get_blast_radius (full impact)
254
+
255
+ Working with class hierarchies?
256
+ -> get_class_hierarchy (extends/implements tree)
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Cross-Cutting Features
262
+
263
+ ### Response Envelope (_meta)
264
+ All tool responses include:
265
+ ```json
266
+ { "_meta": { "totalItems": 50, "returnedItems": 25, "truncated": true, "totalBytes": 12400, "hint": "Use search_symbols to narrow results." } }
267
+ ```
268
+ - Default truncation threshold: 8KB
269
+ - Configurable via CTXO_RESPONSE_LIMIT environment variable
270
+
271
+ ### Intent Filtering
272
+ 4 tools accept `intent` parameter: get_blast_radius, get_logic_slice, find_importers, find_dead_code.
273
+ - Keywords extracted from intent string, matched case-insensitively against symbolId, file, name, kind, edgeKind, reason
274
+ - Multiple keywords use OR logic
275
+ - No intent = full results (backward compatible)
276
+
277
+ ### Symbol ID Format
278
+ All symbols use deterministic IDs: `"<relativePath>::<name>::<kind>"`
279
+ - Example: `"src/core/graph/symbol-graph.ts::SymbolGraph::class"`
280
+ - Valid kinds: function, class, interface, method, variable, type
281
+ - Valid edge kinds: imports, calls, extends, implements, uses
282
+
283
+ ### Resources
284
+ - `ctxo://status` — Health check resource (confirms server is running)
package/llms.txt ADDED
@@ -0,0 +1,72 @@
1
+ # Ctxo MCP Server
2
+
3
+ > AI agents don't fail because they can't code. They fail because they code blind. Ctxo gives them the full picture before they write a single line.
4
+
5
+ Ctxo is a Model Context Protocol (MCP) server that gives AI agents structured context about codebases: symbol graphs, blast radius, architectural overlays, change intelligence, dead code detection, and PR impact analysis.
6
+
7
+ ## Quick Start
8
+
9
+ ```
10
+ npx @ctxo/cli init # Detect languages, install plugins, wire MCP
11
+ npx @ctxo/cli index # Build codebase index
12
+ npx @ctxo/cli # Start MCP server (stdio)
13
+ ```
14
+
15
+ ## Package Layout (v0.7.0-alpha.0, pnpm monorepo)
16
+
17
+ - `@ctxo/cli` — CLI + MCP server (formerly `ctxo-mcp`)
18
+ - `@ctxo/plugin-api` — `CtxoLanguagePlugin` v1 interface (apiVersion, id, extensions, tier, createAdapter)
19
+ - `@ctxo/lang-typescript` — ts-morph full-tier plugin
20
+ - `@ctxo/lang-go` — tree-sitter / gopls plugin
21
+ - `@ctxo/lang-csharp` — Roslyn plugin
22
+
23
+ Language adapters ship as separate npm packages and are discovered by scanning the project `package.json` for `@ctxo/lang-*` or `ctxo-lang-*` dependencies.
24
+
25
+ ## 14 Tools
26
+
27
+ - get_logic_slice: Symbol + transitive dependencies (L1-L4 detail levels)
28
+ - get_blast_radius: What breaks if a symbol changes (3-tier: confirmed/likely/potential)
29
+ - get_architectural_overlay: Project layer map (Domain/Infrastructure/Adapter)
30
+ - get_why_context: Git commit intent + anti-pattern warnings (reverts, rollbacks)
31
+ - get_change_intelligence: Complexity x churn composite score
32
+ - find_dead_code: Unreachable symbols and files
33
+ - get_context_for_task: Task-optimized context (fix/extend/refactor/understand)
34
+ - get_ranked_context: BM25 + PageRank search within token budget
35
+ - search_symbols: Symbol name/regex search across index
36
+ - get_changed_symbols: Symbols in recently changed files (git diff)
37
+ - find_importers: Reverse dependency lookup ("who uses this?")
38
+ - get_class_hierarchy: Class inheritance tree (ancestors + descendants)
39
+ - get_symbol_importance: PageRank centrality ranking
40
+ - get_pr_impact: Full PR risk assessment in a single call
41
+
42
+ ## Tool Selection Guide
43
+
44
+ - Reviewing a PR? -> get_pr_impact
45
+ - About to modify code? -> get_blast_radius
46
+ - Understanding a symbol? -> get_context_for_task(taskType: "understand")
47
+ - Fixing a bug? -> get_context_for_task(taskType: "fix")
48
+ - Refactoring? -> get_context_for_task(taskType: "refactor")
49
+ - Don't know the symbol name? -> search_symbols or get_ranked_context
50
+ - Finding unused code? -> find_dead_code
51
+ - Safe to delete? -> find_importers
52
+
53
+ ## New in v0.7
54
+
55
+ - `ctxo install` — install language plugin packages
56
+ - `ctxo init` — project-aware language detection + plugin wiring
57
+ - `ctxo index --install-missing` — auto-install missing plugins during index
58
+ - `ctxo doctor --fix` — repair common issues
59
+ - `ctxo version` subcommand; `ctxo --version --verbose|--json` for plugin/runtime details
60
+
61
+ ## Key Concepts
62
+
63
+ - Symbol ID format: "file::name::kind" (e.g., "src/foo.ts::myFn::function")
64
+ - All responses include _meta: { totalItems, returnedItems, truncated, totalBytes }
65
+ - 4 tools support intent filtering: get_blast_radius, get_logic_slice, find_importers, find_dead_code
66
+ - Large responses auto-truncated at 8KB (configurable via CTXO_RESPONSE_LIMIT)
67
+
68
+ ## Links
69
+
70
+ - npm: https://www.npmjs.com/package/@ctxo/cli
71
+ - GitHub: https://github.com/alperhankendi/Ctxo
72
+ - Full reference: llms-full.txt
package/package.json CHANGED
@@ -1,13 +1,65 @@
1
- {
2
- "name": "@ctxo/cli",
3
- "version": "0.0.1",
4
- "description": "Reserved for v0.7.0 release — Ctxo CLI + MCP server",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/alperhankendi/Ctxo.git"
9
- },
10
- "publishConfig": {
11
- "access": "public"
12
- }
13
- }
1
+ {
2
+ "name": "@ctxo/cli",
3
+ "version": "0.7.0-alpha.0",
4
+ "description": "MCP server delivering dependency-aware, history-enriched context for codebases",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=20"
8
+ },
9
+ "bin": {
10
+ "ctxo": "dist/index.js"
11
+ },
12
+ "files": [
13
+ "dist/",
14
+ "pages/visualize-template.html",
15
+ "README.md",
16
+ "llms.txt",
17
+ "llms-full.txt"
18
+ ],
19
+ "main": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "keywords": [
22
+ "mcp",
23
+ "context",
24
+ "ai",
25
+ "coding-assistant",
26
+ "dependency-graph"
27
+ ],
28
+ "author": "Alper Hankendi",
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "@clack/prompts": "^1.2.0",
32
+ "@modelcontextprotocol/sdk": "^1.12.1",
33
+ "chokidar": "^5.0.0",
34
+ "picocolors": "^1.1.1",
35
+ "simple-git": "^3.27.0",
36
+ "sql.js": "^1.14.1",
37
+ "zod": "^4.3.6",
38
+ "@ctxo/plugin-api": "0.7.0-alpha.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^22.15.3",
42
+ "@vitest/coverage-v8": "^3.1.3",
43
+ "eslint": "^9.26.0",
44
+ "tsup": "^8.4.0",
45
+ "tsx": "^4.19.4",
46
+ "typescript": "^5.8.3",
47
+ "typescript-eslint": "^8.57.2",
48
+ "vitest": "^3.1.3",
49
+ "@ctxo/lang-go": "0.7.0-alpha.0",
50
+ "@ctxo/lang-csharp": "0.7.0-alpha.0",
51
+ "@ctxo/lang-typescript": "0.7.0-alpha.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsup",
55
+ "dev": "tsx src/index.ts",
56
+ "test": "vitest run",
57
+ "test:unit": "vitest run --config vitest.config.unit.ts",
58
+ "test:unit:coverage": "vitest run --config vitest.config.unit.ts --coverage",
59
+ "test:e2e": "vitest run --config vitest.config.e2e.ts",
60
+ "test:watch": "vitest",
61
+ "test:coverage": "vitest run --coverage",
62
+ "lint": "eslint src/",
63
+ "typecheck": "tsc --noEmit"
64
+ }
65
+ }