豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit a02a567

Browse files
authored
chore: change text format to md in CLI (#1102)
as it is closer to reality.
1 parent 7c9ff36 commit a02a567

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/bin/chrome-devtools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ for (const [commandName, commandDef] of Object.entries(commands)) {
110110
commandDef.description,
111111
y => {
112112
y.option('format', {
113-
choices: ['text', 'json'],
114-
default: 'text',
113+
choices: ['md', 'json'],
114+
default: 'md',
115115
});
116116
for (const [argName, opt] of Object.entries(args)) {
117117
const type =
@@ -173,7 +173,7 @@ for (const [commandName, commandDef] of Object.entries(commands)) {
173173
console.log(
174174
handleResponse(
175175
JSON.parse(response.result) as unknown as CallToolResult,
176-
argv['format'] as 'json' | 'text',
176+
argv['format'] as 'json' | 'md',
177177
),
178178
);
179179
} else {

src/daemon/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export async function stopDaemon() {
146146

147147
export function handleResponse(
148148
response: CallToolResult,
149-
format: 'json' | 'text',
149+
format: 'json' | 'md',
150150
): string {
151151
if (response.isError) {
152152
return JSON.stringify(response.content);
@@ -165,5 +165,5 @@ export function handleResponse(
165165
throw new Error('Not supported response content type');
166166
}
167167
}
168-
return format === 'text' ? chunks.join('') : JSON.stringify(chunks);
168+
return format === 'md' ? chunks.join('') : JSON.stringify(chunks);
169169
}

tests/daemon/client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('daemon client', () => {
5555
describe('parsing', () => {
5656
it('handles MCP response with text format', async () => {
5757
const textResponse = {content: [{type: 'text' as const, text: 'test'}]};
58-
assert.strictEqual(handleResponse(textResponse, 'text'), 'test');
58+
assert.strictEqual(handleResponse(textResponse, 'md'), 'test');
5959
});
6060

6161
it('handles JSON response', async () => {
@@ -78,7 +78,7 @@ describe('daemon client', () => {
7878
content: [{type: 'text' as const, text: 'Something went wrong'}],
7979
};
8080
assert.strictEqual(
81-
handleResponse(errorResponse, 'text'),
81+
handleResponse(errorResponse, 'md'),
8282
JSON.stringify(errorResponse.content),
8383
);
8484
});
@@ -108,7 +108,7 @@ describe('daemon client', () => {
108108
structuredContent: {},
109109
};
110110
assert.throws(
111-
() => handleResponse(unsupportedContentResponse, 'text'),
111+
() => handleResponse(unsupportedContentResponse, 'md'),
112112
new Error('Not supported response content type'),
113113
);
114114
});

0 commit comments

Comments
 (0)