@fabersep/atlas 0.0.0-stage → 0.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/CHANGELOG.md +49 -0
- package/LICENSE +202 -0
- package/README.md +175 -2
- package/dist/packs/csharp/calls.d.ts +4 -0
- package/dist/packs/csharp/calls.js +167 -0
- package/dist/packs/csharp/declarations.d.ts +4 -0
- package/dist/packs/csharp/declarations.js +142 -0
- package/dist/packs/csharp/pack.d.ts +2 -0
- package/dist/packs/csharp/pack.js +39 -0
- package/dist/packs/csharp/resolve.d.ts +2 -0
- package/dist/packs/csharp/resolve.js +35 -0
- package/dist/packs/csharp/signals.d.ts +7 -0
- package/dist/packs/csharp/signals.js +143 -0
- package/dist/packs/dart/calls.d.ts +4 -0
- package/dist/packs/dart/calls.js +130 -0
- package/dist/packs/dart/declarations.d.ts +11 -0
- package/dist/packs/dart/declarations.js +79 -0
- package/dist/packs/dart/members.d.ts +4 -0
- package/dist/packs/dart/members.js +62 -0
- package/dist/packs/dart/pack.d.ts +2 -0
- package/dist/packs/dart/pack.js +37 -0
- package/dist/packs/dart/resolve.d.ts +2 -0
- package/dist/packs/dart/resolve.js +32 -0
- package/dist/packs/index.d.ts +3 -0
- package/dist/packs/index.js +8 -0
- package/dist/packs/json/pack.d.ts +2 -0
- package/dist/packs/json/pack.js +27 -0
- package/dist/packs/msbuild/pack.d.ts +2 -0
- package/dist/packs/msbuild/pack.js +75 -0
- package/dist/packs/msbuild/xml.d.ts +16 -0
- package/dist/packs/msbuild/xml.js +123 -0
- package/dist/packs/typescript/calls.d.ts +4 -0
- package/dist/packs/typescript/calls.js +208 -0
- package/dist/packs/typescript/declarations.d.ts +9 -0
- package/dist/packs/typescript/declarations.js +74 -0
- package/dist/packs/typescript/members.d.ts +4 -0
- package/dist/packs/typescript/members.js +92 -0
- package/dist/packs/typescript/pack.d.ts +2 -0
- package/dist/packs/typescript/pack.js +53 -0
- package/dist/packs/typescript/resolve.d.ts +2 -0
- package/dist/packs/typescript/resolve.js +68 -0
- package/dist/packs/typescript/signals.d.ts +7 -0
- package/dist/packs/typescript/signals.js +310 -0
- package/dist/packs/yaml/pack.d.ts +2 -0
- package/dist/packs/yaml/pack.js +35 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +477 -0
- package/dist/src/context/pre-grep.d.ts +15 -0
- package/dist/src/context/pre-grep.js +79 -0
- package/dist/src/context/pre-invoke.d.ts +20 -0
- package/dist/src/context/pre-invoke.js +127 -0
- package/dist/src/context/pre-prompt.d.ts +16 -0
- package/dist/src/context/pre-prompt.js +66 -0
- package/dist/src/context/session.d.ts +17 -0
- package/dist/src/context/session.js +57 -0
- package/dist/src/graph/build.d.ts +17 -0
- package/dist/src/graph/build.js +41 -0
- package/dist/src/graph/metrics.d.ts +12 -0
- package/dist/src/graph/metrics.js +75 -0
- package/dist/src/graph/topology.d.ts +5 -0
- package/dist/src/graph/topology.js +54 -0
- package/dist/src/health/compare.d.ts +2 -0
- package/dist/src/health/compare.js +38 -0
- package/dist/src/health/duplicates.d.ts +11 -0
- package/dist/src/health/duplicates.js +66 -0
- package/dist/src/health/health.d.ts +12 -0
- package/dist/src/health/health.js +94 -0
- package/dist/src/health/types.d.ts +101 -0
- package/dist/src/health/types.js +5 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.js +22 -0
- package/dist/src/init/init.d.ts +104 -0
- package/dist/src/init/init.js +499 -0
- package/dist/src/init/scout.d.ts +45 -0
- package/dist/src/init/scout.js +217 -0
- package/dist/src/jsonc.d.ts +5 -0
- package/dist/src/jsonc.js +34 -0
- package/dist/src/mcp/server.d.ts +398 -0
- package/dist/src/mcp/server.js +543 -0
- package/dist/src/metrics/doctor.d.ts +15 -0
- package/dist/src/metrics/doctor.js +125 -0
- package/dist/src/metrics/log.d.ts +43 -0
- package/dist/src/metrics/log.js +101 -0
- package/dist/src/metrics/stats.d.ts +43 -0
- package/dist/src/metrics/stats.js +172 -0
- package/dist/src/model.d.ts +178 -0
- package/dist/src/model.js +2 -0
- package/dist/src/outputs.d.ts +16 -0
- package/dist/src/outputs.js +48 -0
- package/dist/src/packs/calls.d.ts +9 -0
- package/dist/src/packs/calls.js +119 -0
- package/dist/src/packs/dataShape.d.ts +6 -0
- package/dist/src/packs/dataShape.js +54 -0
- package/dist/src/packs/pack.d.ts +51 -0
- package/dist/src/packs/pack.js +3 -0
- package/dist/src/packs/packFiles.d.ts +5 -0
- package/dist/src/packs/packFiles.js +12 -0
- package/dist/src/packs/symbols.d.ts +39 -0
- package/dist/src/packs/symbols.js +98 -0
- package/dist/src/packs/treeSitter.d.ts +8 -0
- package/dist/src/packs/treeSitter.js +107 -0
- package/dist/src/queries/flow.d.ts +42 -0
- package/dist/src/queries/flow.js +398 -0
- package/dist/src/queries/investigate.d.ts +43 -0
- package/dist/src/queries/investigate.js +216 -0
- package/dist/src/queries/map.d.ts +28 -0
- package/dist/src/queries/map.js +102 -0
- package/dist/src/queries/neighborhood.d.ts +35 -0
- package/dist/src/queries/neighborhood.js +60 -0
- package/dist/src/queries/search.d.ts +37 -0
- package/dist/src/queries/search.js +279 -0
- package/dist/src/scan/audit.d.ts +2 -0
- package/dist/src/scan/audit.js +41 -0
- package/dist/src/scan/records.d.ts +12 -0
- package/dist/src/scan/records.js +42 -0
- package/dist/src/scan/resolveImports.d.ts +3 -0
- package/dist/src/scan/resolveImports.js +47 -0
- package/dist/src/scan/roles.d.ts +5 -0
- package/dist/src/scan/roles.js +87 -0
- package/dist/src/scan/scan.d.ts +24 -0
- package/dist/src/scan/scan.js +72 -0
- package/dist/src/text/briefs.d.ts +13 -0
- package/dist/src/text/briefs.js +43 -0
- package/dist/src/text/collapse.d.ts +10 -0
- package/dist/src/text/collapse.js +58 -0
- package/dist/src/text/declarations.d.ts +12 -0
- package/dist/src/text/declarations.js +120 -0
- package/dist/src/text/structure.d.ts +2 -0
- package/dist/src/text/structure.js +15 -0
- package/dist/src/text/tree.d.ts +20 -0
- package/dist/src/text/tree.js +49 -0
- package/dist/src/tokens.d.ts +4 -0
- package/dist/src/tokens.js +9 -0
- package/dist/src/version.d.ts +10 -0
- package/dist/src/version.js +11 -0
- package/dist/src/walk/ignoreRules.d.ts +17 -0
- package/dist/src/walk/ignoreRules.js +72 -0
- package/dist/src/walk/walk.d.ts +11 -0
- package/dist/src/walk/walk.js +29 -0
- package/grammars/LICENSE-tree-sitter-dart +20 -0
- package/grammars/README.md +11 -0
- package/grammars/tree-sitter-dart.wasm +0 -0
- package/package.json +68 -4
- package/packs/csharp/README.md +9 -0
- package/packs/csharp/imports.scm +3 -0
- package/packs/csharp/symbols.scm +17 -0
- package/packs/dart/imports.scm +5 -0
- package/packs/dart/symbols.scm +13 -0
- package/packs/msbuild/README.md +11 -0
- package/packs/typescript/exports.scm +16 -0
- package/packs/typescript/imports.scm +9 -0
- package/packs/typescript/symbols.scm +19 -0
- package/schema/ast_code_map.schema.json +144 -0
- package/schema/schema-lock.json +7 -0
- package/schema/topology.schema.json +87 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import readline from 'node:readline/promises';
|
|
6
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
7
|
+
export const SCOUT_BLOCK_START = '<!-- faber-atlas-scout:start -->';
|
|
8
|
+
export const SCOUT_BLOCK_END = '<!-- faber-atlas-scout:end -->';
|
|
9
|
+
export const CLAUDE_SCOUT_TIERS = [
|
|
10
|
+
{ id: 'haiku', label: 'haiku — fastest & cheapest (tracks latest Haiku)', recommended: true },
|
|
11
|
+
{ id: 'sonnet', label: 'sonnet — balanced reasoning for complex repos' },
|
|
12
|
+
{ id: 'opus', label: 'opus — maximum capability (highest cost)' },
|
|
13
|
+
{ id: 'inherit', label: 'inherit — match the primary session model' },
|
|
14
|
+
];
|
|
15
|
+
export const ANTIGRAVITY_SCOUT_TIERS = [
|
|
16
|
+
{ id: 'flash', label: 'flash — fast & cheap read-only explorer', recommended: true },
|
|
17
|
+
{ id: 'flash_lite', label: 'flash_lite — lightest & fastest for simple lookups' },
|
|
18
|
+
{ id: 'pro', label: 'pro — larger model for dense architectures' },
|
|
19
|
+
{ id: 'inherit', label: 'inherit — match the primary session model' },
|
|
20
|
+
];
|
|
21
|
+
export const EFFORT_OPTIONS = ['low', 'medium', 'high'];
|
|
22
|
+
export function defaultScoutModel(engine) {
|
|
23
|
+
return engine === 'claude-code' ? 'haiku' : 'flash';
|
|
24
|
+
}
|
|
25
|
+
export function defaultScoutEffort(engine) {
|
|
26
|
+
return engine === 'claude-code' ? 'low' : undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The Scout lives in the user's own folders, so one setup serves every project. */
|
|
29
|
+
export function claudeScoutFilePath(userHome) {
|
|
30
|
+
return path.join(userHome, '.claude', 'agents', 'atlas-scout.md');
|
|
31
|
+
}
|
|
32
|
+
/** Antigravity's global rules file, read in every workspace. */
|
|
33
|
+
export function antigravityRulesPath(userHome) {
|
|
34
|
+
return path.join(userHome, '.gemini', 'GEMINI.md');
|
|
35
|
+
}
|
|
36
|
+
export const defaultUserHome = () => process.env.FABER_USER_HOME ?? os.homedir();
|
|
37
|
+
export function renderClaudeScoutAgent(model = 'haiku', effort = 'low') {
|
|
38
|
+
return [
|
|
39
|
+
'---',
|
|
40
|
+
'name: atlas-scout',
|
|
41
|
+
'description: Fast, read-only codebase explorer powered by FaberSEP Atlas MCP. Delegate open-ended, multi-file, cross-layer exploration with unknown entry points here before editing.',
|
|
42
|
+
`model: ${model}`,
|
|
43
|
+
`effort: ${effort}`,
|
|
44
|
+
'tools: mcp__faber-atlas__investigate, mcp__faber-atlas__search, mcp__faber-atlas__map, mcp__faber-atlas__brief, mcp__faber-atlas__neighborhood, mcp__faber-atlas__flow, mcp__faber-atlas__impact, mcp__faber-atlas__hubs, mcp__faber-atlas__health, Read, Grep, Glob',
|
|
45
|
+
'---',
|
|
46
|
+
'',
|
|
47
|
+
'You are **Atlas Scout**, a read-only codebase explorer. Your job is to locate exact `file:line` targets, call/event chains, and affected tests for the primary model using minimal turns and tokens.',
|
|
48
|
+
'',
|
|
49
|
+
'## Protocol',
|
|
50
|
+
'1. Start with `investigate(query)` for open-ended questions (returns search hits, flow/impact chains, budgeted code excerpts, and related tests in one call), or `search(query)` / `map(zoom=0)` when you need a layout overview.',
|
|
51
|
+
'2. Trace remaining gaps with `flow(symbol)` (downstream) or `impact(symbol)` (upstream callers & entrypoints).',
|
|
52
|
+
'3. Fetch signatures via `brief(files)` or `neighborhood(files, budget=...)` before reading raw files; `Read` only the lines you must verify.',
|
|
53
|
+
'4. If a tool answers that the folder is not a project, call it again with `root` set to the absolute path of the project.',
|
|
54
|
+
'5. Never edit files.',
|
|
55
|
+
'',
|
|
56
|
+
'## Execution & Budget',
|
|
57
|
+
'- Batch independent tool calls in parallel in the same turn (e.g., multiple `flow`, `impact`, or `Read` calls at once).',
|
|
58
|
+
'- Target at most 4 tool-calling turns (hard stop at 5). Never spiral into single-file sequential reads.',
|
|
59
|
+
'- Use `Grep`/`Glob` as a fallback for literal strings, config keys, or dynamic event/registry wiring that Atlas does not index.',
|
|
60
|
+
'- Keep the final report <= 400 words: verified `file:line` pointers, call/event chains, affected tests, and a 1-line **Coverage** note listing what you searched and any dynamic links you could not statically verify.',
|
|
61
|
+
'',
|
|
62
|
+
].join('\n');
|
|
63
|
+
}
|
|
64
|
+
export function renderAntigravityScoutBlock(model = 'flash') {
|
|
65
|
+
return [
|
|
66
|
+
SCOUT_BLOCK_START,
|
|
67
|
+
'## Atlas Scout (Code Discovery)',
|
|
68
|
+
'',
|
|
69
|
+
`**Route first, before any tool call of your own.** For multi-file trace/flow questions (how X works across layers, what happens when Y, a vague bug report) or open-ended, multi-file, cross-layer exploration with unknown entry points, use a read-only \`atlas-scout\` subagent with MCP access (built-in \`research\` has no MCP tools): call \`define_subagent\` once with \`Name: "atlas-scout"\`, \`EnableMCPTools: true\`, \`EnableWriteTools: false\`, then call \`invoke_subagent\` with \`TypeName: "atlas-scout"\` and \`Model: "${model}"\` (passing the user's question and workspace \`root\`), and answer directly from its report (its \`file:line\` pointers are already verified; only read files if you are editing or the Scout flagged an unverified gap). Do it yourself instead — skip the Scout for a named file or single symbol, literal text, a localized edit, or context already loaded. When the user names a symbol and asks what changing it breaks, call \`faber-atlas\` \`impact\` yourself first (\`call_mcp_tool\` with \`ServerName: "faber-atlas"\`, \`ToolName: "impact"\`, and \`root\`) before any grep or \`run_command\`.`,
|
|
70
|
+
'',
|
|
71
|
+
'SystemPrompt / instructions for `atlas-scout`:',
|
|
72
|
+
'1. Start with `call_mcp_tool(ServerName: "faber-atlas", ToolName: "investigate", Arguments: {query, root})` (or `search` / `map` zoom=0) and batch independent `flow`/`impact`/`read_file` calls in parallel — target at most 4 turns (hard stop at 5).',
|
|
73
|
+
'2. Use `Grep`/`Glob` only as a fallback for literal strings, config keys, or dynamic event/registry wiring that Atlas does not index.',
|
|
74
|
+
'3. Return a report <= 400 words with verified `file:line` pointers, call/event chains, affected tests, and a 1-line **Coverage** note.',
|
|
75
|
+
'4. Antigravity starts the `faber-atlas` server outside the workspace, so pass `root` (the absolute path of the workspace you are working in) on every `faber-atlas` call.',
|
|
76
|
+
SCOUT_BLOCK_END,
|
|
77
|
+
].join('\n');
|
|
78
|
+
}
|
|
79
|
+
function escapeRegex(s) {
|
|
80
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
81
|
+
}
|
|
82
|
+
export function upsertScoutBlock(existing, block) {
|
|
83
|
+
const regex = new RegExp(`${escapeRegex(SCOUT_BLOCK_START)}[\\s\\S]*?${escapeRegex(SCOUT_BLOCK_END)}`, 'g');
|
|
84
|
+
if (regex.test(existing)) {
|
|
85
|
+
let first = true;
|
|
86
|
+
const replaced = existing.replace(regex, () => {
|
|
87
|
+
if (first) {
|
|
88
|
+
first = false;
|
|
89
|
+
return block;
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
});
|
|
93
|
+
return `${replaced.replace(/\n{3,}/g, '\n\n').trimEnd()}\n`;
|
|
94
|
+
}
|
|
95
|
+
const trimmed = existing.trimEnd();
|
|
96
|
+
return trimmed ? `${trimmed}\n\n${block}\n` : `${block}\n`;
|
|
97
|
+
}
|
|
98
|
+
export function removeScoutBlock(existing) {
|
|
99
|
+
const regex = new RegExp(`\\n?${escapeRegex(SCOUT_BLOCK_START)}[\\s\\S]*?${escapeRegex(SCOUT_BLOCK_END)}\\n?`, 'g');
|
|
100
|
+
const next = existing.replace(regex, '\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
101
|
+
return next ? `${next}\n` : '';
|
|
102
|
+
}
|
|
103
|
+
export function readCurrentScoutConfigs(userHome = defaultUserHome()) {
|
|
104
|
+
const results = [];
|
|
105
|
+
// Claude Code
|
|
106
|
+
const claudeFile = claudeScoutFilePath(userHome);
|
|
107
|
+
if (fs.existsSync(claudeFile)) {
|
|
108
|
+
const raw = fs.readFileSync(claudeFile, 'utf8');
|
|
109
|
+
const model = raw.match(/^model:\s*(.+)$/m)?.[1]?.trim() ?? defaultScoutModel('claude-code');
|
|
110
|
+
const effortRaw = raw.match(/^effort:\s*(low|medium|high)$/m)?.[1];
|
|
111
|
+
results.push({ engine: 'claude-code', model, effort: effortRaw ?? 'low', filePath: claudeFile, installed: true });
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
results.push({ engine: 'claude-code', model: defaultScoutModel('claude-code'), effort: 'low', filePath: claudeFile, installed: false });
|
|
115
|
+
}
|
|
116
|
+
// Antigravity (managed block in its global rules)
|
|
117
|
+
const agentsFile = antigravityRulesPath(userHome);
|
|
118
|
+
if (fs.existsSync(agentsFile)) {
|
|
119
|
+
const raw = fs.readFileSync(agentsFile, 'utf8');
|
|
120
|
+
const hasBlock = raw.includes(SCOUT_BLOCK_START);
|
|
121
|
+
const block = raw.slice(raw.indexOf(SCOUT_BLOCK_START));
|
|
122
|
+
const model = (hasBlock ? block.match(/Model:\s*"([^"]+)"/)?.[1]?.trim() : undefined) ?? defaultScoutModel('antigravity');
|
|
123
|
+
results.push({ engine: 'antigravity', model, filePath: agentsFile, installed: hasBlock });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
results.push({ engine: 'antigravity', model: defaultScoutModel('antigravity'), filePath: agentsFile, installed: false });
|
|
127
|
+
}
|
|
128
|
+
return results;
|
|
129
|
+
}
|
|
130
|
+
export function setScoutConfig(options) {
|
|
131
|
+
const userHome = options.userHome ?? defaultUserHome();
|
|
132
|
+
if (options.engine === 'claude-code') {
|
|
133
|
+
const filePath = claudeScoutFilePath(userHome);
|
|
134
|
+
const effort = options.effort ?? 'low';
|
|
135
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
136
|
+
fs.writeFileSync(filePath, renderClaudeScoutAgent(options.model, effort), 'utf8');
|
|
137
|
+
return { engine: 'claude-code', model: options.model, effort, filePath, installed: true };
|
|
138
|
+
}
|
|
139
|
+
const filePath = antigravityRulesPath(userHome);
|
|
140
|
+
const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
|
|
141
|
+
const updated = upsertScoutBlock(existing, renderAntigravityScoutBlock(options.model));
|
|
142
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
143
|
+
fs.writeFileSync(filePath, updated, 'utf8');
|
|
144
|
+
return { engine: 'antigravity', model: options.model, filePath, installed: true };
|
|
145
|
+
}
|
|
146
|
+
/** Optional live model discovery for Antigravity (`agy models`), with safe offline fallback. */
|
|
147
|
+
export function discoverLiveAgyModels(timeoutMs = 4000) {
|
|
148
|
+
try {
|
|
149
|
+
const out = execFileSync('agy', ['models'], { encoding: 'utf8', timeout: timeoutMs, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
150
|
+
const lines = out.split('\n').map((l) => l.trim()).filter(Boolean);
|
|
151
|
+
return { ok: true, lines };
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
155
|
+
return {
|
|
156
|
+
ok: false,
|
|
157
|
+
lines: [],
|
|
158
|
+
note: `Could not query "agy models" (${msg.split('\n')[0]}). Using stable tier aliases instead.`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export function formatScoutStatus(configs) {
|
|
163
|
+
const lines = ['FaberSEP Atlas — Scout Configuration', ''];
|
|
164
|
+
for (const cfg of configs) {
|
|
165
|
+
const state = cfg.installed ? 'configured' : 'not configured';
|
|
166
|
+
const effortStr = cfg.engine === 'claude-code'
|
|
167
|
+
? ` | effort: ${cfg.effort ?? 'low'}`
|
|
168
|
+
: ' | effort: n/a (subagent uses tier alias only)';
|
|
169
|
+
lines.push(` [${cfg.engine}] ${state} — model: ${cfg.model}${effortStr}`);
|
|
170
|
+
lines.push(` file: ${cfg.filePath}`);
|
|
171
|
+
}
|
|
172
|
+
lines.push('');
|
|
173
|
+
lines.push('Change anytime:');
|
|
174
|
+
lines.push(' faber-atlas scout --engine claude-code --model haiku --effort low');
|
|
175
|
+
lines.push(' faber-atlas scout --engine antigravity --model flash');
|
|
176
|
+
return lines.join('\n');
|
|
177
|
+
}
|
|
178
|
+
export async function runInteractiveScout(userHome, preferredEngine) {
|
|
179
|
+
const rl = readline.createInterface({ input, output });
|
|
180
|
+
try {
|
|
181
|
+
let engine = preferredEngine;
|
|
182
|
+
if (!engine) {
|
|
183
|
+
output.write('\nSelect target environment:\n 1) claude-code (subagent: .claude/agents/atlas-scout.md)\n 2) antigravity (Scout rules in ~/.gemini/GEMINI.md)\n');
|
|
184
|
+
const ans = (await rl.question('Choice [1]: ')).trim();
|
|
185
|
+
engine = ans === '2' ? 'antigravity' : 'claude-code';
|
|
186
|
+
}
|
|
187
|
+
const tiers = engine === 'claude-code' ? CLAUDE_SCOUT_TIERS : ANTIGRAVITY_SCOUT_TIERS;
|
|
188
|
+
output.write(`\nAvailable Scout models for ${engine}:\n`);
|
|
189
|
+
tiers.forEach((t, i) => {
|
|
190
|
+
output.write(` ${i + 1}) ${t.label}${t.recommended ? ' [recommended]' : ''}\n`);
|
|
191
|
+
});
|
|
192
|
+
output.write(` ${tiers.length + 1}) Custom model name\n`);
|
|
193
|
+
const modelChoice = (await rl.question('Choice [1]: ')).trim();
|
|
194
|
+
const idx = modelChoice ? Number(modelChoice) - 1 : 0;
|
|
195
|
+
let model = tiers[0].id;
|
|
196
|
+
if (idx >= 0 && idx < tiers.length) {
|
|
197
|
+
model = tiers[idx].id;
|
|
198
|
+
}
|
|
199
|
+
else if (idx === tiers.length) {
|
|
200
|
+
const custom = (await rl.question('Enter model name: ')).trim();
|
|
201
|
+
if (custom)
|
|
202
|
+
model = custom;
|
|
203
|
+
}
|
|
204
|
+
let effort;
|
|
205
|
+
if (engine === 'claude-code') {
|
|
206
|
+
output.write('\nSelect reasoning effort (low is fastest and recommended for Scout):\n 1) low [recommended]\n 2) medium\n 3) high\n');
|
|
207
|
+
const effChoice = (await rl.question('Choice [1]: ')).trim();
|
|
208
|
+
effort = effChoice === '2' ? 'medium' : effChoice === '3' ? 'high' : 'low';
|
|
209
|
+
}
|
|
210
|
+
const saved = setScoutConfig({ userHome, engine, model, effort });
|
|
211
|
+
output.write(`\nSaved ${saved.engine} Scout -> model: ${saved.model}${saved.effort ? `, effort: ${saved.effort}` : ''} (${saved.filePath})\n`);
|
|
212
|
+
return saved;
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
rl.close();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses JSON that may hold comments and trailing commas (tsconfig.json, VS Code settings). Strings are copied as
|
|
3
|
+
* they are, so a `//` inside a string is kept. Invalid JSON throws, as JSON.parse does.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseJsonc(text: string): unknown;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses JSON that may hold comments and trailing commas (tsconfig.json, VS Code settings). Strings are copied as
|
|
3
|
+
* they are, so a `//` inside a string is kept. Invalid JSON throws, as JSON.parse does.
|
|
4
|
+
*/
|
|
5
|
+
export function parseJsonc(text) {
|
|
6
|
+
let out = '';
|
|
7
|
+
for (let i = 0; i < text.length; i++) {
|
|
8
|
+
const ch = text[i];
|
|
9
|
+
if (ch === '"') {
|
|
10
|
+
const end = stringEnd(text, i);
|
|
11
|
+
out += text.slice(i, end);
|
|
12
|
+
i = end - 1;
|
|
13
|
+
}
|
|
14
|
+
else if (ch === '/' && text[i + 1] === '/') {
|
|
15
|
+
while (i < text.length && text[i] !== '\n')
|
|
16
|
+
i++;
|
|
17
|
+
out += '\n';
|
|
18
|
+
}
|
|
19
|
+
else if (ch === '/' && text[i + 1] === '*') {
|
|
20
|
+
const close = text.indexOf('*/', i + 2);
|
|
21
|
+
i = close === -1 ? text.length : close + 1;
|
|
22
|
+
}
|
|
23
|
+
else if (ch !== ',' || !/^\s*[}\]]/.test(text.slice(i + 1, i + 200)))
|
|
24
|
+
out += ch;
|
|
25
|
+
}
|
|
26
|
+
return JSON.parse(out);
|
|
27
|
+
}
|
|
28
|
+
/** The index just after the string that starts at `start`. */
|
|
29
|
+
function stringEnd(text, start) {
|
|
30
|
+
let i = start + 1;
|
|
31
|
+
while (i < text.length && text[i] !== '"')
|
|
32
|
+
i += text[i] === '\\' ? 2 : 1;
|
|
33
|
+
return i + 1;
|
|
34
|
+
}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
import type { CodeMap, Topology } from '../model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Thin zero-dependency stdio MCP server (`faber-atlas mcp`).
|
|
5
|
+
* Exposes `map`, `brief`, `neighborhood`, `flow`, `impact`, `hubs`, and `health`
|
|
6
|
+
* with automatic incremental freshness before every query.
|
|
7
|
+
*/
|
|
8
|
+
export interface McpServerOptions {
|
|
9
|
+
/** Project to scan and query. Default: the client's workspace root, else the git root above the current folder. */
|
|
10
|
+
root?: string;
|
|
11
|
+
/** Folder the server starts in (default: process.cwd()); tests set it. */
|
|
12
|
+
cwd?: string;
|
|
13
|
+
/** The user's home folder, which is never mapped as a whole (default: os.homedir()). */
|
|
14
|
+
userHome?: string;
|
|
15
|
+
/** Output directory for `.faber-atlas` artifacts (default: `<root>/.faber-atlas`). */
|
|
16
|
+
out?: string;
|
|
17
|
+
/** Run incremental scan automatically before each query (default: true). */
|
|
18
|
+
fresh?: boolean;
|
|
19
|
+
/** Where startup diagnostics go (default: stderr, which MCP clients keep in their logs). */
|
|
20
|
+
log?: (message: string) => void;
|
|
21
|
+
/** Streams for stdio transport (defaults to process.stdin / process.stdout). */
|
|
22
|
+
input?: Readable;
|
|
23
|
+
output?: Writable;
|
|
24
|
+
}
|
|
25
|
+
interface JsonRpcRequest {
|
|
26
|
+
jsonrpc: '2.0';
|
|
27
|
+
id?: string | number | null;
|
|
28
|
+
method: string;
|
|
29
|
+
params?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
interface JsonRpcResponse {
|
|
32
|
+
jsonrpc: '2.0';
|
|
33
|
+
id: string | number | null;
|
|
34
|
+
method?: string;
|
|
35
|
+
result?: unknown;
|
|
36
|
+
error?: {
|
|
37
|
+
code: number;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Shown by clients in the system prompt even while tool schemas are deferred (02/AC-23). */
|
|
42
|
+
export declare const SERVER_INSTRUCTIONS: string;
|
|
43
|
+
export declare const MCP_TOOLS: readonly [{
|
|
44
|
+
readonly name: "investigate";
|
|
45
|
+
readonly _meta: {
|
|
46
|
+
readonly 'anthropic/alwaysLoad': true;
|
|
47
|
+
};
|
|
48
|
+
readonly description: "One-call context pack for a code question: combines structural search hits, non-trivial flow/impact chains, line-numbered source excerpts within a token budget, and related test files.";
|
|
49
|
+
readonly inputSchema: {
|
|
50
|
+
readonly type: "object";
|
|
51
|
+
readonly required: readonly ["query"];
|
|
52
|
+
readonly properties: {
|
|
53
|
+
readonly root: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
56
|
+
};
|
|
57
|
+
readonly query: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly description: "Question keywords, symbol name, route, event, or job name.";
|
|
60
|
+
};
|
|
61
|
+
readonly budget: {
|
|
62
|
+
readonly type: "integer";
|
|
63
|
+
readonly minimum: 400;
|
|
64
|
+
readonly maximum: 16000;
|
|
65
|
+
readonly description: "Token budget for the pack (default: 3000).";
|
|
66
|
+
};
|
|
67
|
+
readonly folder: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
readonly description: "Optional subfolder prefix to restrict search.";
|
|
70
|
+
};
|
|
71
|
+
readonly limit: {
|
|
72
|
+
readonly type: "integer";
|
|
73
|
+
readonly minimum: 1;
|
|
74
|
+
readonly maximum: 20;
|
|
75
|
+
readonly description: "Maximum search hits to consider (default: 8).";
|
|
76
|
+
};
|
|
77
|
+
readonly depth: {
|
|
78
|
+
readonly type: "integer";
|
|
79
|
+
readonly minimum: 1;
|
|
80
|
+
readonly maximum: 5;
|
|
81
|
+
readonly description: "Flow/impact traversal depth (default: 2).";
|
|
82
|
+
};
|
|
83
|
+
readonly includeTests: {
|
|
84
|
+
readonly type: "boolean";
|
|
85
|
+
readonly description: "Include test/spec files in search and chains (default: false).";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "search";
|
|
91
|
+
readonly _meta: {
|
|
92
|
+
readonly 'anthropic/alwaysLoad': true;
|
|
93
|
+
};
|
|
94
|
+
readonly description: "Fast structural search across symbols, files, HTTP routes, events, and jobs. Returns file:line, signatures, entrypoints, and call/event/job links in one step. Use before Grep or Glob.";
|
|
95
|
+
readonly inputSchema: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly required: readonly ["query"];
|
|
98
|
+
readonly properties: {
|
|
99
|
+
readonly root: {
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
102
|
+
};
|
|
103
|
+
readonly query: {
|
|
104
|
+
readonly type: "string";
|
|
105
|
+
readonly description: "Keywords, symbol name, route, event, or job name (e.g. \"validateApiKey\", \"storage path\", \"AssetExtractMetadata\").";
|
|
106
|
+
};
|
|
107
|
+
readonly folder: {
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
readonly description: "Optional subfolder prefix to restrict search.";
|
|
110
|
+
};
|
|
111
|
+
readonly limit: {
|
|
112
|
+
readonly type: "integer";
|
|
113
|
+
readonly minimum: 1;
|
|
114
|
+
readonly maximum: 50;
|
|
115
|
+
readonly description: "Maximum hits to return (default: 12).";
|
|
116
|
+
};
|
|
117
|
+
readonly includeTests: {
|
|
118
|
+
readonly type: "boolean";
|
|
119
|
+
readonly description: "Include test/spec files (default: false).";
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "map";
|
|
125
|
+
readonly _meta: {
|
|
126
|
+
readonly 'anthropic/alwaysLoad': true;
|
|
127
|
+
};
|
|
128
|
+
readonly description: "Layered structural map of the codebase. Start with zoom=0 (~200 tokens) to see folders and roles, then zoom=1 on relevant folders (files + top-level symbols, tests excluded) before calling brief, flow, or impact.";
|
|
129
|
+
readonly inputSchema: {
|
|
130
|
+
readonly type: "object";
|
|
131
|
+
readonly properties: {
|
|
132
|
+
readonly root: {
|
|
133
|
+
readonly type: "string";
|
|
134
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
135
|
+
};
|
|
136
|
+
readonly folder: {
|
|
137
|
+
readonly type: "string";
|
|
138
|
+
readonly description: "Optional subfolder or file path relative to repo root.";
|
|
139
|
+
};
|
|
140
|
+
readonly zoom: {
|
|
141
|
+
readonly type: "integer";
|
|
142
|
+
readonly enum: readonly [0, 1, 2];
|
|
143
|
+
readonly description: "0: folders with counts & roles; 1: files + top-level symbols (default); 2: method-level compact map.";
|
|
144
|
+
};
|
|
145
|
+
readonly includeTests: {
|
|
146
|
+
readonly type: "boolean";
|
|
147
|
+
readonly description: "Include test/spec files in zoom 0/1 maps (default: false).";
|
|
148
|
+
};
|
|
149
|
+
readonly fields: {
|
|
150
|
+
readonly type: "boolean";
|
|
151
|
+
readonly description: "Include fields and getters in zoom 2 summaries.";
|
|
152
|
+
};
|
|
153
|
+
readonly full: {
|
|
154
|
+
readonly type: "boolean";
|
|
155
|
+
readonly description: "Print full public declaration signatures.";
|
|
156
|
+
};
|
|
157
|
+
readonly depth: {
|
|
158
|
+
readonly type: "integer";
|
|
159
|
+
readonly minimum: 0;
|
|
160
|
+
readonly description: "Maximum folder depth below root.";
|
|
161
|
+
};
|
|
162
|
+
readonly foldersOnly: {
|
|
163
|
+
readonly type: "boolean";
|
|
164
|
+
readonly description: "Print folder structure only.";
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "brief";
|
|
170
|
+
readonly description: "Compact declaration skeletons (signatures, roles, entrypoints, thrown exceptions — without bodies) for one or more files.";
|
|
171
|
+
readonly inputSchema: {
|
|
172
|
+
readonly type: "object";
|
|
173
|
+
readonly required: readonly ["files"];
|
|
174
|
+
readonly properties: {
|
|
175
|
+
readonly root: {
|
|
176
|
+
readonly type: "string";
|
|
177
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
178
|
+
};
|
|
179
|
+
readonly files: {
|
|
180
|
+
readonly type: "array";
|
|
181
|
+
readonly items: {
|
|
182
|
+
readonly type: "string";
|
|
183
|
+
};
|
|
184
|
+
readonly minItems: 1;
|
|
185
|
+
readonly description: "Project-relative file paths.";
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
}, {
|
|
190
|
+
readonly name: "neighborhood";
|
|
191
|
+
readonly description: "Target file(s) plus their direct imports and importers (and optionally second ring within a token budget) with briefs.";
|
|
192
|
+
readonly inputSchema: {
|
|
193
|
+
readonly type: "object";
|
|
194
|
+
readonly required: readonly ["files"];
|
|
195
|
+
readonly properties: {
|
|
196
|
+
readonly root: {
|
|
197
|
+
readonly type: "string";
|
|
198
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
199
|
+
};
|
|
200
|
+
readonly files: {
|
|
201
|
+
readonly type: "array";
|
|
202
|
+
readonly items: {
|
|
203
|
+
readonly type: "string";
|
|
204
|
+
};
|
|
205
|
+
readonly minItems: 1;
|
|
206
|
+
readonly description: "Project-relative target file paths.";
|
|
207
|
+
};
|
|
208
|
+
readonly budget: {
|
|
209
|
+
readonly type: "integer";
|
|
210
|
+
readonly minimum: 1;
|
|
211
|
+
readonly description: "Optional token budget to include second-ring dependencies.";
|
|
212
|
+
};
|
|
213
|
+
readonly list: {
|
|
214
|
+
readonly type: "boolean";
|
|
215
|
+
readonly description: "Return only file paths and token counts without briefs.";
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
}, {
|
|
220
|
+
readonly name: "flow";
|
|
221
|
+
readonly _meta: {
|
|
222
|
+
readonly 'anthropic/alwaysLoad': true;
|
|
223
|
+
};
|
|
224
|
+
readonly description: "Trace downstream execution flow from a symbol (e.g. \"AuthController.changePassword\", \"OrderService.place\", \"event:OrderPlaced\", \"job:SendReceipt\") across calls, inherited fields, interface implementations, @OnEvent, @OnJob, and C# MediatR handlers.";
|
|
225
|
+
readonly inputSchema: {
|
|
226
|
+
readonly type: "object";
|
|
227
|
+
readonly required: readonly ["symbol"];
|
|
228
|
+
readonly properties: {
|
|
229
|
+
readonly root: {
|
|
230
|
+
readonly type: "string";
|
|
231
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
232
|
+
};
|
|
233
|
+
readonly symbol: {
|
|
234
|
+
readonly type: "string";
|
|
235
|
+
readonly description: "Symbol name: Class.method, file#Class.method, functionName, event:<name>, or job:<name>.";
|
|
236
|
+
};
|
|
237
|
+
readonly depth: {
|
|
238
|
+
readonly type: "integer";
|
|
239
|
+
readonly minimum: 1;
|
|
240
|
+
readonly maximum: 10;
|
|
241
|
+
readonly description: "Maximum traversal depth (default: 4).";
|
|
242
|
+
};
|
|
243
|
+
readonly includeTests: {
|
|
244
|
+
readonly type: "boolean";
|
|
245
|
+
readonly description: "Include test files in traversal (default: false).";
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
}, {
|
|
250
|
+
readonly name: "impact";
|
|
251
|
+
readonly _meta: {
|
|
252
|
+
readonly 'anthropic/alwaysLoad': true;
|
|
253
|
+
};
|
|
254
|
+
readonly description: "Trace upstream callers and entrypoints (HTTP routes, events, jobs) that reach a symbol.";
|
|
255
|
+
readonly inputSchema: {
|
|
256
|
+
readonly type: "object";
|
|
257
|
+
readonly required: readonly ["symbol"];
|
|
258
|
+
readonly properties: {
|
|
259
|
+
readonly root: {
|
|
260
|
+
readonly type: "string";
|
|
261
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
262
|
+
};
|
|
263
|
+
readonly symbol: {
|
|
264
|
+
readonly type: "string";
|
|
265
|
+
readonly description: "Symbol name: Class.method, file#Class.method, functionName, event:<name>, or job:<name>.";
|
|
266
|
+
};
|
|
267
|
+
readonly depth: {
|
|
268
|
+
readonly type: "integer";
|
|
269
|
+
readonly minimum: 1;
|
|
270
|
+
readonly maximum: 10;
|
|
271
|
+
readonly description: "Maximum traversal depth (default: 4).";
|
|
272
|
+
};
|
|
273
|
+
readonly includeTests: {
|
|
274
|
+
readonly type: "boolean";
|
|
275
|
+
readonly description: "Include test files in traversal (default: false).";
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
}, {
|
|
280
|
+
readonly name: "hubs";
|
|
281
|
+
readonly description: "List the most central/connected files in the dependency graph by centrality score and PageRank.";
|
|
282
|
+
readonly inputSchema: {
|
|
283
|
+
readonly type: "object";
|
|
284
|
+
readonly properties: {
|
|
285
|
+
readonly root: {
|
|
286
|
+
readonly type: "string";
|
|
287
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
288
|
+
};
|
|
289
|
+
readonly top: {
|
|
290
|
+
readonly type: "integer";
|
|
291
|
+
readonly minimum: 1;
|
|
292
|
+
readonly maximum: 100;
|
|
293
|
+
readonly description: "Number of top hubs to return (default: 10).";
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
}, {
|
|
298
|
+
readonly name: "health";
|
|
299
|
+
readonly description: "Check code health against explicit limits (file length, function length, nesting depth, duplicate blocks, import cycles).";
|
|
300
|
+
readonly inputSchema: {
|
|
301
|
+
readonly type: "object";
|
|
302
|
+
readonly required: readonly ["maxFileLines", "maxFunctionLines", "hardFunctionLines", "maxNestingDepth", "minDuplicateLines"];
|
|
303
|
+
readonly properties: {
|
|
304
|
+
readonly root: {
|
|
305
|
+
readonly type: "string";
|
|
306
|
+
readonly description: "Absolute project path; pass it when Atlas asks for it.";
|
|
307
|
+
};
|
|
308
|
+
readonly maxFileLines: {
|
|
309
|
+
readonly type: "integer";
|
|
310
|
+
readonly minimum: 1;
|
|
311
|
+
};
|
|
312
|
+
readonly maxFunctionLines: {
|
|
313
|
+
readonly type: "integer";
|
|
314
|
+
readonly minimum: 1;
|
|
315
|
+
};
|
|
316
|
+
readonly hardFunctionLines: {
|
|
317
|
+
readonly type: "integer";
|
|
318
|
+
readonly minimum: 1;
|
|
319
|
+
};
|
|
320
|
+
readonly maxNestingDepth: {
|
|
321
|
+
readonly type: "integer";
|
|
322
|
+
readonly minimum: 0;
|
|
323
|
+
};
|
|
324
|
+
readonly minDuplicateLines: {
|
|
325
|
+
readonly type: "integer";
|
|
326
|
+
readonly minimum: 1;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
}];
|
|
331
|
+
/** Ensures `.faber-atlas` outputs are up to date via incremental scan (re-parses only modified files). */
|
|
332
|
+
export declare function ensureFreshIndex(root: string, out: string): Promise<{
|
|
333
|
+
map: CodeMap;
|
|
334
|
+
topology: Topology;
|
|
335
|
+
}>;
|
|
336
|
+
/** The nearest folder at or above `start` that holds `.git`; `start` itself when there is none. */
|
|
337
|
+
export declare function projectRootFrom(start: string): string;
|
|
338
|
+
/** Atlas refuses to map the whole home folder or the file system root (an AI tool opened outside any project). */
|
|
339
|
+
export declare class NoProjectError extends Error {
|
|
340
|
+
constructor(folder: string);
|
|
341
|
+
}
|
|
342
|
+
/** Workspace folders a client reported through MCP `roots/list` (file URIs only). */
|
|
343
|
+
export declare function rootsToPaths(result: unknown): string[];
|
|
344
|
+
export declare class McpHandler {
|
|
345
|
+
private readonly explicitRoot?;
|
|
346
|
+
private readonly explicitOut?;
|
|
347
|
+
private readonly cwd;
|
|
348
|
+
private readonly userHome;
|
|
349
|
+
private readonly fresh;
|
|
350
|
+
private clientRoots;
|
|
351
|
+
private rootsWaiter;
|
|
352
|
+
private releaseRoots?;
|
|
353
|
+
private queue;
|
|
354
|
+
/** Set by `initialize` when the client can answer `roots/list`. */
|
|
355
|
+
clientHasRoots: boolean;
|
|
356
|
+
constructor(options?: McpServerOptions);
|
|
357
|
+
/**
|
|
358
|
+
* The project this server maps (02/AC-18): `--root` when given; else the git root at or above the client's workspace
|
|
359
|
+
* root (the one holding the start folder, or the first), or above the folder the tool started the server in.
|
|
360
|
+
*/
|
|
361
|
+
get root(): string;
|
|
362
|
+
get out(): string;
|
|
363
|
+
/**
|
|
364
|
+
* The project a call maps (02/AC-18, 02/AC-20): `--root`; else the call's own `root` argument; else the git root
|
|
365
|
+
* at or above the client's workspace root (the one holding the start folder, or the first), or above the folder
|
|
366
|
+
* the tool started the server in. Never the home folder or `/`.
|
|
367
|
+
*/
|
|
368
|
+
resolveRoot(argRoot?: unknown): string;
|
|
369
|
+
private outFor;
|
|
370
|
+
/** Set by serveMcp: sends a new roots/list request (and makes calls wait for it). */
|
|
371
|
+
requestRoots?: () => void;
|
|
372
|
+
/** True when the project can only come from the client: no --root, no root argument, no roots yet, start folder not a project. */
|
|
373
|
+
private needsClientRoots;
|
|
374
|
+
/** A `roots/list` request is on its way; tool calls wait for its answer (at most `timeoutMs`). */
|
|
375
|
+
expectRoots(timeoutMs?: number): void;
|
|
376
|
+
setClientRoots(result: unknown): void;
|
|
377
|
+
private loadIndex;
|
|
378
|
+
/** Tool calls run one at a time, so two scans never write the same index together. */
|
|
379
|
+
callToolQueued(name: string, args?: Record<string, unknown>): Promise<{
|
|
380
|
+
content: Array<{
|
|
381
|
+
type: "text";
|
|
382
|
+
text: string;
|
|
383
|
+
}>;
|
|
384
|
+
isError?: boolean;
|
|
385
|
+
}>;
|
|
386
|
+
private record;
|
|
387
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<{
|
|
388
|
+
content: Array<{
|
|
389
|
+
type: 'text';
|
|
390
|
+
text: string;
|
|
391
|
+
}>;
|
|
392
|
+
isError?: boolean;
|
|
393
|
+
}>;
|
|
394
|
+
handleMessage(req: JsonRpcRequest): Promise<JsonRpcResponse | undefined>;
|
|
395
|
+
}
|
|
396
|
+
/** Runs the stdio MCP server until the input stream closes. */
|
|
397
|
+
export declare function serveMcp(options?: McpServerOptions): Promise<void>;
|
|
398
|
+
export {};
|