Skip to content

Commit 9b919df

Browse files
refactor: inject context capture adapters as data
Pass lintCaptureAdapter and testCaptureDependencies to createContextMcpServer instead of wrapping captureLintSnapshot and captureTestSnapshot wholesale, so upstream capture signature growth no longer needs matching wrapper updates here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b19ae33 commit 9b919df

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

‎packages/rstack/src/mcp.ts‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { Writable } from 'node:stream';
44
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
55
import { resolveContextWorkspace } from '@rstackjs/context';
66
import { createContextMcpServer } from '@rstackjs/context/mcp';
7-
import { captureLintSnapshot } from '@rstackjs/context/rslint';
8-
import { captureTestSnapshot } from '@rstackjs/context/rstest';
97
import { loadRstackConfig, withRstackConfigTarget } from './config.ts';
108
import { resolveRelatedTests } from './relatedTests.ts';
119

@@ -34,23 +32,20 @@ const runContextMcpServer = async (startPath: string): Promise<void> => {
3432
const { workspaceRoot } = await resolveContextWorkspace(startPath);
3533
const server = createContextMcpServer(workspaceRoot, {
3634
serverVersion: RSTACK_VERSION,
37-
captureLintSnapshot: (root, request, createRslint) =>
38-
captureLintSnapshot(root, request, createRslint, {
39-
wrapperConfigPath: path.join(import.meta.dirname, 'rslintConfig.js'),
40-
withConfigTarget: withRstackConfigTarget,
41-
}),
42-
captureTestSnapshot: (root, request, dependencies = {}) =>
43-
captureTestSnapshot(root, request, {
44-
...dependencies,
45-
wrapperConfigPath: path.join(import.meta.dirname, 'rstestConfig.js'),
46-
withConfigTarget: withRstackConfigTarget,
47-
resolveRelatedTests,
48-
isTestConfigured: ({ packageRoot, configPath }) =>
49-
withRstackConfigTarget(packageRoot, configPath, async () => {
50-
const { configs } = await loadRstackConfig();
51-
return configs.test !== undefined;
52-
}),
53-
}),
35+
lintCaptureAdapter: {
36+
wrapperConfigPath: path.join(import.meta.dirname, 'rslintConfig.js'),
37+
withConfigTarget: withRstackConfigTarget,
38+
},
39+
testCaptureDependencies: {
40+
wrapperConfigPath: path.join(import.meta.dirname, 'rstestConfig.js'),
41+
withConfigTarget: withRstackConfigTarget,
42+
resolveRelatedTests,
43+
isTestConfigured: ({ packageRoot, configPath }) =>
44+
withRstackConfigTarget(packageRoot, configPath, async () => {
45+
const { configs } = await loadRstackConfig();
46+
return configs.test !== undefined;
47+
}),
48+
},
5449
});
5550

5651
await server.connect(new StdioServerTransport(process.stdin, reserveStandardOutputForProtocol()));

0 commit comments

Comments
 (0)