typegraph-mcp 0.9.33 → 0.9.34
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/cli.ts +35 -24
- package/dist/cli.js +32 -23
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -40,10 +40,25 @@ interface AgentDef {
|
|
|
40
40
|
const AGENT_SNIPPET = `
|
|
41
41
|
## TypeScript Navigation (typegraph-mcp)
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Where suitable, use the \`ts_*\` MCP tools instead of grep/glob for navigating TypeScript code. They resolve through barrel files, re-exports, and project references and return semantic results instead of string matches.
|
|
44
44
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
45
|
+
- Point queries: \`ts_find_symbol\`, \`ts_definition\`, \`ts_references\`, \`ts_type_info\`, \`ts_navigate_to\`, \`ts_trace_chain\`, \`ts_blast_radius\`, \`ts_module_exports\`
|
|
46
|
+
- Graph queries: \`ts_dependency_tree\`, \`ts_dependents\`, \`ts_import_cycles\`, \`ts_shortest_path\`, \`ts_subgraph\`, \`ts_module_boundary\`
|
|
47
|
+
|
|
48
|
+
Start with the navigation tools before reading entire files. Use direct file reads only after the MCP tools identify the exact symbols or lines that matter.
|
|
49
|
+
|
|
50
|
+
Use \`rg\` or \`grep\` when semantic symbol navigation is not the right tool, especially for:
|
|
51
|
+
|
|
52
|
+
- docs, config, SQL, migrations, JSON, env vars, route strings, and other non-TypeScript assets
|
|
53
|
+
- broad text discovery when you do not yet know the symbol name
|
|
54
|
+
- exact string matching across the repo
|
|
55
|
+
- validating wording or finding repeated plan/document references
|
|
56
|
+
|
|
57
|
+
Practical rule:
|
|
58
|
+
|
|
59
|
+
- use \`ts_*\` first for TypeScript symbol definition, references, types, and dependency analysis
|
|
60
|
+
- use \`rg\`/\`grep\` for text search and non-TypeScript exploration
|
|
61
|
+
- combine both when a task spans TypeScript code and surrounding docs/config
|
|
47
62
|
`.trimStart();
|
|
48
63
|
|
|
49
64
|
const SNIPPET_MARKER = "## TypeScript Navigation (typegraph-mcp)";
|
|
@@ -808,39 +823,35 @@ async function setupAgentInstructions(projectRoot: string, selectedAgents: Agent
|
|
|
808
823
|
return; // No agents with instruction files selected (e.g. Cursor only)
|
|
809
824
|
}
|
|
810
825
|
|
|
811
|
-
//
|
|
826
|
+
// Ensure each selected agent file exists and has the snippet once. Resolve
|
|
827
|
+
// symlinks to avoid writing duplicate content through multiple aliases.
|
|
812
828
|
const seenRealPaths = new Map<string, string>(); // realPath -> first agentFile name
|
|
813
|
-
const existingFiles: { file: string; realPath: string; hasSnippet: boolean }[] = [];
|
|
814
829
|
for (const agentFile of agentFiles) {
|
|
815
830
|
const filePath = path.resolve(projectRoot, agentFile);
|
|
816
|
-
if (!fs.existsSync(filePath))
|
|
817
|
-
|
|
831
|
+
if (!fs.existsSync(filePath)) {
|
|
832
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
833
|
+
fs.writeFileSync(filePath, AGENT_SNIPPET + "\n");
|
|
834
|
+
p.log.success(`${agentFile}: created with typegraph-mcp instructions`);
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
818
837
|
|
|
838
|
+
const realPath = fs.realpathSync(filePath);
|
|
819
839
|
const previousFile = seenRealPaths.get(realPath);
|
|
820
840
|
if (previousFile) {
|
|
821
841
|
p.log.info(`${agentFile}: same file as ${previousFile} (skipped)`);
|
|
822
842
|
continue;
|
|
823
843
|
}
|
|
824
|
-
seenRealPaths.set(realPath, agentFile);
|
|
825
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
826
|
-
existingFiles.push({ file: agentFile, realPath, hasSnippet: content.includes(SNIPPET_MARKER) });
|
|
827
|
-
}
|
|
828
844
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
if (f.hasSnippet) {
|
|
835
|
-
p.log.info(`${f.file}: already has typegraph-mcp instructions`);
|
|
836
|
-
}
|
|
845
|
+
seenRealPaths.set(realPath, agentFile);
|
|
846
|
+
const content = fs.readFileSync(realPath, "utf-8");
|
|
847
|
+
if (content.includes(SNIPPET_MARKER)) {
|
|
848
|
+
p.log.info(`${agentFile}: already has typegraph-mcp instructions`);
|
|
849
|
+
continue;
|
|
837
850
|
}
|
|
838
|
-
|
|
839
|
-
const target = existingFiles[0]!;
|
|
840
|
-
const content = fs.readFileSync(target.realPath, "utf-8");
|
|
851
|
+
|
|
841
852
|
const appendContent = (content.endsWith("\n") ? "" : "\n") + "\n" + AGENT_SNIPPET;
|
|
842
|
-
fs.appendFileSync(
|
|
843
|
-
p.log.success(`${
|
|
853
|
+
fs.appendFileSync(realPath, appendContent);
|
|
854
|
+
p.log.success(`${agentFile}: appended typegraph-mcp instructions`);
|
|
844
855
|
}
|
|
845
856
|
|
|
846
857
|
// Update --plugin-dir line in CLAUDE.md if Claude Code is selected
|
package/dist/cli.js
CHANGED
|
@@ -526,9 +526,9 @@ async function main(configOverride) {
|
|
|
526
526
|
console.log(` Fix: ${fix}`);
|
|
527
527
|
failed++;
|
|
528
528
|
}
|
|
529
|
-
function warn(msg,
|
|
529
|
+
function warn(msg, note) {
|
|
530
530
|
console.log(` ! ${msg}`);
|
|
531
|
-
console.log(` ${
|
|
531
|
+
console.log(` ${note}`);
|
|
532
532
|
warned++;
|
|
533
533
|
}
|
|
534
534
|
function skip(msg) {
|
|
@@ -2915,10 +2915,25 @@ import * as p from "@clack/prompts";
|
|
|
2915
2915
|
var AGENT_SNIPPET = `
|
|
2916
2916
|
## TypeScript Navigation (typegraph-mcp)
|
|
2917
2917
|
|
|
2918
|
-
|
|
2918
|
+
Where suitable, use the \`ts_*\` MCP tools instead of grep/glob for navigating TypeScript code. They resolve through barrel files, re-exports, and project references and return semantic results instead of string matches.
|
|
2919
2919
|
|
|
2920
|
-
-
|
|
2921
|
-
-
|
|
2920
|
+
- Point queries: \`ts_find_symbol\`, \`ts_definition\`, \`ts_references\`, \`ts_type_info\`, \`ts_navigate_to\`, \`ts_trace_chain\`, \`ts_blast_radius\`, \`ts_module_exports\`
|
|
2921
|
+
- Graph queries: \`ts_dependency_tree\`, \`ts_dependents\`, \`ts_import_cycles\`, \`ts_shortest_path\`, \`ts_subgraph\`, \`ts_module_boundary\`
|
|
2922
|
+
|
|
2923
|
+
Start with the navigation tools before reading entire files. Use direct file reads only after the MCP tools identify the exact symbols or lines that matter.
|
|
2924
|
+
|
|
2925
|
+
Use \`rg\` or \`grep\` when semantic symbol navigation is not the right tool, especially for:
|
|
2926
|
+
|
|
2927
|
+
- docs, config, SQL, migrations, JSON, env vars, route strings, and other non-TypeScript assets
|
|
2928
|
+
- broad text discovery when you do not yet know the symbol name
|
|
2929
|
+
- exact string matching across the repo
|
|
2930
|
+
- validating wording or finding repeated plan/document references
|
|
2931
|
+
|
|
2932
|
+
Practical rule:
|
|
2933
|
+
|
|
2934
|
+
- use \`ts_*\` first for TypeScript symbol definition, references, types, and dependency analysis
|
|
2935
|
+
- use \`rg\`/\`grep\` for text search and non-TypeScript exploration
|
|
2936
|
+
- combine both when a task spans TypeScript code and surrounding docs/config
|
|
2922
2937
|
`.trimStart();
|
|
2923
2938
|
var SNIPPET_MARKER = "## TypeScript Navigation (typegraph-mcp)";
|
|
2924
2939
|
var PLUGIN_DIR_NAME = "plugins/typegraph-mcp";
|
|
@@ -3496,10 +3511,14 @@ async function setupAgentInstructions(projectRoot3, selectedAgents) {
|
|
|
3496
3511
|
return;
|
|
3497
3512
|
}
|
|
3498
3513
|
const seenRealPaths = /* @__PURE__ */ new Map();
|
|
3499
|
-
const existingFiles = [];
|
|
3500
3514
|
for (const agentFile of agentFiles) {
|
|
3501
3515
|
const filePath = path9.resolve(projectRoot3, agentFile);
|
|
3502
|
-
if (!fs8.existsSync(filePath))
|
|
3516
|
+
if (!fs8.existsSync(filePath)) {
|
|
3517
|
+
fs8.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
3518
|
+
fs8.writeFileSync(filePath, AGENT_SNIPPET + "\n");
|
|
3519
|
+
p.log.success(`${agentFile}: created with typegraph-mcp instructions`);
|
|
3520
|
+
continue;
|
|
3521
|
+
}
|
|
3503
3522
|
const realPath = fs8.realpathSync(filePath);
|
|
3504
3523
|
const previousFile = seenRealPaths.get(realPath);
|
|
3505
3524
|
if (previousFile) {
|
|
@@ -3507,24 +3526,14 @@ async function setupAgentInstructions(projectRoot3, selectedAgents) {
|
|
|
3507
3526
|
continue;
|
|
3508
3527
|
}
|
|
3509
3528
|
seenRealPaths.set(realPath, agentFile);
|
|
3510
|
-
const content = fs8.readFileSync(
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
p.log.warn(`No agent instruction files found (${agentFiles.join(", ")})`);
|
|
3515
|
-
p.note(AGENT_SNIPPET, "Add this snippet to your agent instructions file");
|
|
3516
|
-
} else if (existingFiles.some((f) => f.hasSnippet)) {
|
|
3517
|
-
for (const f of existingFiles) {
|
|
3518
|
-
if (f.hasSnippet) {
|
|
3519
|
-
p.log.info(`${f.file}: already has typegraph-mcp instructions`);
|
|
3520
|
-
}
|
|
3529
|
+
const content = fs8.readFileSync(realPath, "utf-8");
|
|
3530
|
+
if (content.includes(SNIPPET_MARKER)) {
|
|
3531
|
+
p.log.info(`${agentFile}: already has typegraph-mcp instructions`);
|
|
3532
|
+
continue;
|
|
3521
3533
|
}
|
|
3522
|
-
} else {
|
|
3523
|
-
const target = existingFiles[0];
|
|
3524
|
-
const content = fs8.readFileSync(target.realPath, "utf-8");
|
|
3525
3534
|
const appendContent = (content.endsWith("\n") ? "" : "\n") + "\n" + AGENT_SNIPPET;
|
|
3526
|
-
fs8.appendFileSync(
|
|
3527
|
-
p.log.success(`${
|
|
3535
|
+
fs8.appendFileSync(realPath, appendContent);
|
|
3536
|
+
p.log.success(`${agentFile}: appended typegraph-mcp instructions`);
|
|
3528
3537
|
}
|
|
3529
3538
|
if (selectedAgents.includes("claude-code")) {
|
|
3530
3539
|
const claudeMdPath = path9.resolve(projectRoot3, "CLAUDE.md");
|