codetree-claude 1.5.0 → 1.5.2
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/README.md +137 -121
- package/dist/cli.js +69 -83
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +126 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -1
- package/dist/diff.d.ts +37 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +181 -0
- package/dist/diff.js.map +1 -0
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +139 -0
- package/dist/doctor.js.map +1 -0
- package/dist/hook/post-compact.js +1 -23
- package/dist/hook/post-compact.js.map +1 -1
- package/dist/hook/post-tool-use.js +11 -27
- package/dist/hook/post-tool-use.js.map +1 -1
- package/dist/hook/pre-compact.js +1 -22
- package/dist/hook/pre-compact.js.map +1 -1
- package/dist/hook/pre-tool-use.bundled.js +49 -77
- package/dist/hook/pre-tool-use.js +23 -90
- package/dist/hook/pre-tool-use.js.map +1 -1
- package/dist/hook/session-start.js +19 -23
- package/dist/hook/session-start.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer/extractor-registry.d.ts.map +1 -1
- package/dist/indexer/extractor-registry.js +6 -0
- package/dist/indexer/extractor-registry.js.map +1 -1
- package/dist/indexer/extractors/csharp.d.ts +12 -0
- package/dist/indexer/extractors/csharp.d.ts.map +1 -0
- package/dist/indexer/extractors/csharp.js +165 -0
- package/dist/indexer/extractors/csharp.js.map +1 -0
- package/dist/indexer/extractors/go.js +44 -1
- package/dist/indexer/extractors/go.js.map +1 -1
- package/dist/indexer/extractors/java.d.ts.map +1 -1
- package/dist/indexer/extractors/java.js +41 -3
- package/dist/indexer/extractors/java.js.map +1 -1
- package/dist/indexer/extractors/javascript.d.ts.map +1 -1
- package/dist/indexer/extractors/javascript.js +67 -3
- package/dist/indexer/extractors/javascript.js.map +1 -1
- package/dist/indexer/extractors/python.d.ts.map +1 -1
- package/dist/indexer/extractors/python.js +31 -2
- package/dist/indexer/extractors/python.js.map +1 -1
- package/dist/indexer/extractors/ruby.d.ts +10 -0
- package/dist/indexer/extractors/ruby.d.ts.map +1 -0
- package/dist/indexer/extractors/ruby.js +145 -0
- package/dist/indexer/extractors/ruby.js.map +1 -0
- package/dist/indexer/extractors/rust.d.ts +10 -0
- package/dist/indexer/extractors/rust.d.ts.map +1 -0
- package/dist/indexer/extractors/rust.js +194 -0
- package/dist/indexer/extractors/rust.js.map +1 -0
- package/dist/indexer/indexer.d.ts +15 -0
- package/dist/indexer/indexer.d.ts.map +1 -1
- package/dist/indexer/indexer.js +168 -4
- package/dist/indexer/indexer.js.map +1 -1
- package/dist/server/ipc.d.ts +10 -4
- package/dist/server/ipc.d.ts.map +1 -1
- package/dist/server/ipc.js +190 -109
- package/dist/server/ipc.js.map +1 -1
- package/dist/server/mcp-server.js +36 -27
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tools/codetree-find-refs.d.ts.map +1 -1
- package/dist/server/tools/codetree-find-refs.js +23 -14
- package/dist/server/tools/codetree-find-refs.js.map +1 -1
- package/dist/server/tools/codetree-memory.d.ts +3 -6
- package/dist/server/tools/codetree-memory.d.ts.map +1 -1
- package/dist/server/tools/codetree-memory.js +9 -10
- package/dist/server/tools/codetree-memory.js.map +1 -1
- package/dist/server/tools/codetree-outline.d.ts +57 -0
- package/dist/server/tools/codetree-outline.d.ts.map +1 -0
- package/dist/server/tools/codetree-outline.js +76 -0
- package/dist/server/tools/codetree-outline.js.map +1 -0
- package/dist/server/tools/codetree-probe.d.ts +53 -0
- package/dist/server/tools/codetree-probe.d.ts.map +1 -0
- package/dist/server/tools/codetree-probe.js +81 -0
- package/dist/server/tools/codetree-probe.js.map +1 -0
- package/dist/server/tools/codetree-read.d.ts +52 -3
- package/dist/server/tools/codetree-read.d.ts.map +1 -1
- package/dist/server/tools/codetree-read.js +237 -55
- package/dist/server/tools/codetree-read.js.map +1 -1
- package/dist/server/tools/codetree-search.d.ts +13 -1
- package/dist/server/tools/codetree-search.d.ts.map +1 -1
- package/dist/server/tools/codetree-search.js +80 -52
- package/dist/server/tools/codetree-search.js.map +1 -1
- package/dist/server/tools/codetree-structure.d.ts +25 -1
- package/dist/server/tools/codetree-structure.d.ts.map +1 -1
- package/dist/server/tools/codetree-structure.js +92 -42
- package/dist/server/tools/codetree-structure.js.map +1 -1
- package/dist/server/tools/codetree-summary.d.ts +2 -0
- package/dist/server/tools/codetree-summary.d.ts.map +1 -1
- package/dist/server/tools/codetree-summary.js +5 -0
- package/dist/server/tools/codetree-summary.js.map +1 -1
- package/dist/setup/install.d.ts +45 -1
- package/dist/setup/install.d.ts.map +1 -1
- package/dist/setup/install.js +163 -58
- package/dist/setup/install.js.map +1 -1
- package/dist/setup/template-load.d.ts +9 -0
- package/dist/setup/template-load.d.ts.map +1 -0
- package/dist/setup/template-load.js +39 -0
- package/dist/setup/template-load.js.map +1 -0
- package/dist/storage/database.d.ts +49 -0
- package/dist/storage/database.d.ts.map +1 -1
- package/dist/storage/database.js +383 -43
- package/dist/storage/database.js.map +1 -1
- package/dist/storage/disk-manager.d.ts.map +1 -1
- package/dist/storage/disk-manager.js +1 -5
- package/dist/storage/disk-manager.js.map +1 -1
- package/dist/utils.d.ts +23 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +102 -0
- package/dist/utils.js.map +1 -0
- package/package.json +46 -10
- package/templates/README.md +15 -0
- package/templates/agents-codetree.snippet.md +24 -0
- package/templates/claude-md-codetree.snippet.md +22 -0
- package/templates/claude-rules-codetree.md +23 -0
- package/templates/cursor-codetree.mdc +31 -0
- package/templates/gemini-codetree.snippet.md +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disk-manager.js","sourceRoot":"","sources":["../../src/storage/disk-manager.ts"],"names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C,OAAO,GAAG,UAAU,OAAO,kCAAkC,iBAAiB,sCAAsC,CAAC;QACvH,CAAC;QAED,OAAO;YACL,UAAU;YACV,SAAS;YACT,WAAW;YACX,UAAU;YACV,OAAO;YACP,iBAAiB;YACjB,OAAO;SACR,CAAC;IACJ,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IAC3C,CAAC;CACF"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find all git repos under a starting directory up to maxDepth.
|
|
3
|
+
*/
|
|
4
|
+
export declare function findGitRepos(startDir: string, maxDepth?: number): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Walk up from __dirname (or a starting dir) looking for package.json
|
|
7
|
+
* to find the npm package root.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findPackageRoot(startDir: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Format a large number for display (e.g. 1234 -> "1.2K").
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatNumber(n: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Escape a string for use in a RegExp.
|
|
16
|
+
*/
|
|
17
|
+
export declare function escapeRegex(str: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Find the IPC port by looking for .codetree/ipc.port file.
|
|
20
|
+
* Walks up from startDir to find the project root.
|
|
21
|
+
*/
|
|
22
|
+
export declare function findIpcPort(startDir: string): number | null;
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,MAAM,EAAE,CAgCrE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAcxD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiB3D"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
2
|
+
import { join, resolve, dirname } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Find all git repos under a starting directory up to maxDepth.
|
|
5
|
+
*/
|
|
6
|
+
export function findGitRepos(startDir, maxDepth = 3) {
|
|
7
|
+
const repos = [];
|
|
8
|
+
const visited = new Set();
|
|
9
|
+
function walk(dir, depth) {
|
|
10
|
+
if (depth > maxDepth)
|
|
11
|
+
return;
|
|
12
|
+
const resolved = resolve(dir);
|
|
13
|
+
if (visited.has(resolved))
|
|
14
|
+
return;
|
|
15
|
+
visited.add(resolved);
|
|
16
|
+
if (existsSync(join(resolved, ".git"))) {
|
|
17
|
+
repos.push(resolved);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let entries;
|
|
21
|
+
try {
|
|
22
|
+
entries = readdirSync(resolved, { withFileTypes: true });
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const skip = new Set(["node_modules", ".git", "dist", "build", ".next", "__pycache__", ".codetree", ".cache"]);
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
if (!entry.isDirectory())
|
|
30
|
+
continue;
|
|
31
|
+
if (skip.has(entry.name) || entry.name.startsWith("."))
|
|
32
|
+
continue;
|
|
33
|
+
walk(join(resolved, entry.name), depth + 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
walk(startDir, 0);
|
|
37
|
+
return repos;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Walk up from __dirname (or a starting dir) looking for package.json
|
|
41
|
+
* to find the npm package root.
|
|
42
|
+
*/
|
|
43
|
+
export function findPackageRoot(startDir) {
|
|
44
|
+
let dir = resolve(startDir);
|
|
45
|
+
try {
|
|
46
|
+
dir = realpathSync(dir);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* keep dir if symlink resolution fails */
|
|
50
|
+
}
|
|
51
|
+
for (let i = 0; i < 10; i++) {
|
|
52
|
+
if (existsSync(join(dir, "package.json")))
|
|
53
|
+
return dir;
|
|
54
|
+
const parent = resolve(dir, "..");
|
|
55
|
+
if (parent === dir)
|
|
56
|
+
break;
|
|
57
|
+
dir = parent;
|
|
58
|
+
}
|
|
59
|
+
return resolve(startDir, "..");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Format a large number for display (e.g. 1234 -> "1.2K").
|
|
63
|
+
*/
|
|
64
|
+
export function formatNumber(n) {
|
|
65
|
+
if (n < 1_000)
|
|
66
|
+
return String(n);
|
|
67
|
+
if (n < 1_000_000)
|
|
68
|
+
return `${(n / 1_000).toFixed(1)}K`;
|
|
69
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Escape a string for use in a RegExp.
|
|
73
|
+
*/
|
|
74
|
+
export function escapeRegex(str) {
|
|
75
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Find the IPC port by looking for .codetree/ipc.port file.
|
|
79
|
+
* Walks up from startDir to find the project root.
|
|
80
|
+
*/
|
|
81
|
+
export function findIpcPort(startDir) {
|
|
82
|
+
let dir = startDir;
|
|
83
|
+
for (let i = 0; i < 10; i++) {
|
|
84
|
+
const portFile = join(dir, ".codetree", "ipc.port");
|
|
85
|
+
if (existsSync(portFile)) {
|
|
86
|
+
try {
|
|
87
|
+
const port = parseInt(readFileSync(portFile, "utf-8").trim(), 10);
|
|
88
|
+
if (port > 0 && port <= 65535)
|
|
89
|
+
return port;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const parent = dirname(dir);
|
|
96
|
+
if (parent === dir)
|
|
97
|
+
break;
|
|
98
|
+
dir = parent;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,QAAQ,GAAG,CAAC;IACzD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,SAAS,IAAI,CAAC,GAAW,EAAE,KAAa;QACtC,IAAI,KAAK,GAAG,QAAQ;YAAE,OAAO;QAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAO;QAClC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEtB,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,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,OAAO,IAAI,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codetree-claude",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "MCP server
|
|
3
|
+
"version": "1.5.2",
|
|
4
|
+
"description": "MCP server & CLI: codebase index + cache for Claude Code, Cursor, OpenAI Codex, Google Antigravity/Gemini. Model Context Protocol tools (codetree_read, codetree_search, …), hooks on Claude, rules on other IDEs. Token savings, SQLite index, symbol search, session memory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -11,39 +11,74 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|
|
13
13
|
".codetreerc.default.json",
|
|
14
|
-
"README.md"
|
|
14
|
+
"README.md",
|
|
15
|
+
"templates/"
|
|
15
16
|
],
|
|
16
17
|
"keywords": [
|
|
17
18
|
"claude",
|
|
18
19
|
"claude-code",
|
|
19
20
|
"claude-code-cache",
|
|
20
21
|
"anthropic",
|
|
22
|
+
"anthropic-claude",
|
|
21
23
|
"mcp",
|
|
22
24
|
"mcp-server",
|
|
23
25
|
"mcp-tools",
|
|
24
26
|
"model-context-protocol",
|
|
27
|
+
"model-context",
|
|
28
|
+
"stdio-mcp",
|
|
29
|
+
"ai-coding-assistant",
|
|
30
|
+
"ai-code-completion",
|
|
31
|
+
"ai-developer-tools",
|
|
32
|
+
"pair-programming",
|
|
33
|
+
"coding-agent",
|
|
25
34
|
"codebase-cache",
|
|
26
35
|
"codebase-index",
|
|
36
|
+
"repository-index",
|
|
37
|
+
"code-indexer",
|
|
38
|
+
"sqlite",
|
|
27
39
|
"token-optimization",
|
|
28
40
|
"token-saving",
|
|
41
|
+
"context-window",
|
|
42
|
+
"context-engineering",
|
|
43
|
+
"llm",
|
|
44
|
+
"llm-tools",
|
|
45
|
+
"rag-alternative",
|
|
29
46
|
"ai",
|
|
30
47
|
"ai-coding",
|
|
31
|
-
"ai-developer-tools",
|
|
32
48
|
"developer-tools",
|
|
33
|
-
"code-indexer",
|
|
34
49
|
"file-cache",
|
|
35
50
|
"symbol-search",
|
|
51
|
+
"static-analysis",
|
|
52
|
+
"code-intelligence",
|
|
36
53
|
"session-memory",
|
|
37
|
-
"context-window",
|
|
38
54
|
"compaction",
|
|
39
55
|
"vscode",
|
|
56
|
+
"vscode-extension",
|
|
40
57
|
"cursor",
|
|
58
|
+
"cursor-ide",
|
|
59
|
+
"cursor-ai",
|
|
60
|
+
"cursor-rules",
|
|
61
|
+
"cursor-mcp",
|
|
41
62
|
"windsurf",
|
|
42
63
|
"copilot",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
64
|
+
"github-copilot-alternative",
|
|
65
|
+
"openai",
|
|
66
|
+
"openai-codex",
|
|
67
|
+
"codex",
|
|
68
|
+
"codex-cli",
|
|
69
|
+
"codex-mcp",
|
|
70
|
+
"google",
|
|
71
|
+
"google-antigravity",
|
|
72
|
+
"antigravity",
|
|
73
|
+
"gemini",
|
|
74
|
+
"gemini-cli",
|
|
75
|
+
"gemini-code",
|
|
76
|
+
"google-ai",
|
|
77
|
+
"typescript",
|
|
78
|
+
"javascript",
|
|
79
|
+
"python",
|
|
80
|
+
"nodejs",
|
|
81
|
+
"monorepo"
|
|
47
82
|
],
|
|
48
83
|
"repository": {
|
|
49
84
|
"type": "git",
|
|
@@ -64,6 +99,7 @@
|
|
|
64
99
|
"node": ">=20"
|
|
65
100
|
},
|
|
66
101
|
"dependencies": {
|
|
102
|
+
"@iarna/toml": "^3.0.0",
|
|
67
103
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
68
104
|
"chokidar": "^3.6.0",
|
|
69
105
|
"ignore": "^5.3.2",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# CodeTree bundled templates (`codetree init`)
|
|
2
|
+
|
|
3
|
+
These files are **shipped inside the `codetree-claude` npm package** and copied into your repo when you run `codetree init`. Edit the generated files in your project if you need custom wording; to reset, run `codetree init` again (idempotent blocks).
|
|
4
|
+
|
|
5
|
+
| Template | Written to | Used by |
|
|
6
|
+
|----------|------------|---------|
|
|
7
|
+
| `cursor-codetree.mdc` | `.cursor/rules/codetree.mdc` | **Cursor** — project rules (alwaysApply) |
|
|
8
|
+
| `claude-rules-codetree.md` | `.claude/rules/codetree.md` | **Claude Code** — mandatory rules |
|
|
9
|
+
| `claude-md-codetree.snippet.md` | block inside `CLAUDE.md` | **Claude Code** — suggested workflow |
|
|
10
|
+
| `agents-codetree.snippet.md` | block inside `AGENTS.md` | **Cursor, Codex CLI, Antigravity**, and other tools that read `AGENTS.md` |
|
|
11
|
+
| `gemini-codetree.snippet.md` | block inside `GEMINI.md` | **Google Antigravity** / Gemini-first flows |
|
|
12
|
+
|
|
13
|
+
**Antigravity (Google):** MCP is registered in **`.antigravity/mcp.json`**. Steering text is in **`AGENTS.md`** (portable) and **`GEMINI.md`** (Gemini-focused pointer). There is no separate Antigravity-only rules file in this package; those two files are what most agentic IDEs load.
|
|
14
|
+
|
|
15
|
+
**OpenAI Codex:** MCP is in **`.codex/config.toml`** (`[mcp_servers.codetree]`). Steering matches **`AGENTS.md`**; trust the project in Codex if required.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!-- codetree-agents -->
|
|
2
|
+
## CodeTree — token-saving MCP tools (Cursor, Codex, Antigravity, …)
|
|
3
|
+
|
|
4
|
+
This repo registers the **CodeTree** MCP server. Use the cheapest tool that answers the question:
|
|
5
|
+
|
|
6
|
+
| Goal | Tool | Why it's cheap |
|
|
7
|
+
|------|------|----------------|
|
|
8
|
+
| What does file X export? | `codetree_outline` | Symbols + imports + size, **no body** |
|
|
9
|
+
| Does file X mention Y? | `codetree_probe` | Line numbers only, **no snippets** |
|
|
10
|
+
| Find a symbol | `codetree_search` (small `limit`, `cursor` for paging) | Index-only |
|
|
11
|
+
| Browse the tree | `codetree_structure` (`format='text'`) | Compact text, ~40% fewer tokens than JSON |
|
|
12
|
+
| Read content | `codetree_read` (`session_id` + `expected_hash`) | Skips body when unchanged since your last read |
|
|
13
|
+
| Find references | `codetree_find_refs` | Token postings + index |
|
|
14
|
+
| Project overview | `codetree_summary` | Includes per-file `estimatedTokens` |
|
|
15
|
+
| Memory across sessions | `codetree_memory` | `get_context`, `save_insight` |
|
|
16
|
+
|
|
17
|
+
Rules:
|
|
18
|
+
|
|
19
|
+
- **Do not re-read** a file when its `hash` matches your prior response.
|
|
20
|
+
- Pass `session_id` to `codetree_read` so the server can return `unchanged_since_last_read`.
|
|
21
|
+
- Prefer `codetree_outline` → `codetree_probe` → `codetree_search` → `codetree_read`.
|
|
22
|
+
|
|
23
|
+
Run `codetree init` from the repo root if MCP is not configured.
|
|
24
|
+
<!-- /codetree-agents -->
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!-- codetree-instructions -->
|
|
2
|
+
## CodeTree — Cached Codebase Access
|
|
3
|
+
|
|
4
|
+
This project has CodeTree MCP tools for faster, token-efficient codebase access.
|
|
5
|
+
**Use these instead of native Read/Grep/Glob whenever possible:**
|
|
6
|
+
|
|
7
|
+
| Instead of | Use | Why |
|
|
8
|
+
|-----------|-----|-----|
|
|
9
|
+
| `Read` | `codetree_read` | Cached content + symbol metadata |
|
|
10
|
+
| `Grep` | `codetree_search` | Instant symbol index search. Set `content_search=true` for line matches |
|
|
11
|
+
| `Glob` | `codetree_structure` | Indexed project tree with language stats |
|
|
12
|
+
|
|
13
|
+
**Other tools:**
|
|
14
|
+
- `codetree_find_refs` — Find all references to a symbol
|
|
15
|
+
- `codetree_summary` — Project overview (call at session start)
|
|
16
|
+
- `codetree_memory` — Save/recall insights across sessions
|
|
17
|
+
|
|
18
|
+
**Session workflow:**
|
|
19
|
+
1. Start: call `codetree_summary` and `codetree_memory` with `action: "get_context"`
|
|
20
|
+
2. During work: use `codetree_read`/`codetree_search` instead of native tools
|
|
21
|
+
3. Save discoveries: `codetree_memory` with `action: "save_insight"`
|
|
22
|
+
<!-- /codetree-instructions -->
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MANDATORY: Use CodeTree MCP tools instead of native Read/Grep/Glob, and prefer cheaper tools first.
|
|
2
|
+
|
|
3
|
+
Tool ladder (cheapest → most expensive — pick the cheapest that answers the question):
|
|
4
|
+
|
|
5
|
+
1. `codetree_outline` — file shape (exports, imports, size, hash). NO body.
|
|
6
|
+
2. `codetree_probe` — does file X mention Y? Line numbers only, NO snippets.
|
|
7
|
+
3. `codetree_search` — symbol search; small `limit`, use `cursor` for pagination.
|
|
8
|
+
4. `codetree_structure` — project tree; pass `format='text'` for compact output.
|
|
9
|
+
5. `codetree_read` — full content. ALWAYS pass `session_id` so the server can return
|
|
10
|
+
`unchanged_since_last_read` when you've already read the same content this session.
|
|
11
|
+
If you saved the previous response's `hash`, pass it as `expected_hash` to skip the body.
|
|
12
|
+
6. `codetree_find_refs` — cross-file references.
|
|
13
|
+
7. `codetree_edit` / `codetree_write` — edit/write without a prior Read.
|
|
14
|
+
|
|
15
|
+
Rules:
|
|
16
|
+
|
|
17
|
+
- DO NOT re-read a file with the same hash you already saw — refer to your prior response.
|
|
18
|
+
- Use `codetree_summary` at session start; it includes per-file `estimatedTokens` so you can
|
|
19
|
+
rank what to read by **cost**.
|
|
20
|
+
- Use `codetree_memory` action `get_context` to recall prior sessions; `save_insight` for
|
|
21
|
+
durable findings (architecture, bug causes, key decisions).
|
|
22
|
+
|
|
23
|
+
These tools serve cached data and save tokens. ALWAYS prefer them.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: CodeTree — token-saving MCP tools for reads, search, file tree, outlines, probes
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CodeTree
|
|
7
|
+
|
|
8
|
+
Use CodeTree MCP tools instead of default file/search tools when available, and follow these
|
|
9
|
+
token-saving rules:
|
|
10
|
+
|
|
11
|
+
- `codetree_outline` — prefer this over `codetree_read` when you only need a file's exports/shape.
|
|
12
|
+
It returns symbols, imports, hash, and size. **No body**, much cheaper than reading.
|
|
13
|
+
- `codetree_probe` — prefer this over `codetree_search` when you only need to know "where does X
|
|
14
|
+
appear?". Returns line numbers only, **no snippets**.
|
|
15
|
+
- `codetree_read` — for actual content. ALWAYS pass `session_id` so the server can short-circuit
|
|
16
|
+
with `unchanged_since_last_read` when you've already read the same content this session. If you
|
|
17
|
+
saved the previous response's `hash`, pass it as `expected_hash` to skip the body entirely.
|
|
18
|
+
- `codetree_read` returns `hash` + `estimatedTokens`-style metadata. **Do not re-read** a file with
|
|
19
|
+
the same hash; refer to your prior response.
|
|
20
|
+
- `codetree_search` — small `limit` is fine; pass `cursor` if you need more. Use
|
|
21
|
+
`include_signature=false` (default) for fuzzy queries.
|
|
22
|
+
- `codetree_structure` — pass `format='text'` for ~40% fewer tokens than JSON when you just want
|
|
23
|
+
to scan the tree.
|
|
24
|
+
- `codetree_summary` — at session start, gives `totalEstimatedTokens` and per-file estimates;
|
|
25
|
+
use them to rank what to read by **cost**.
|
|
26
|
+
- `codetree_memory` — `get_context` for prior sessions; `save_insight` for durable findings.
|
|
27
|
+
- `codetree_find_refs` for references; `codetree_edit` / `codetree_write` when editing through
|
|
28
|
+
CodeTree (no prior Read needed).
|
|
29
|
+
|
|
30
|
+
These tools use the indexed cache and reduce token usage. Prefer cheaper tools first
|
|
31
|
+
(outline → probe → search → read).
|