@vibe-forge/mcp 0.8.0 → 0.8.4

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/AGENTS.md CHANGED
@@ -34,6 +34,6 @@
34
34
 
35
35
  ## 相关文档
36
36
 
37
- - [架构说明](/Users/bytedance/projects/vibe-forge.ai/.ai/rules/docs/ARCHITECTURE.md)
38
- - [使用文档](/Users/bytedance/projects/vibe-forge.ai/.ai/rules/docs/USAGE.md)
37
+ - [架构说明](/Users/bytedance/projects/vibe-forge.ai/.ai/rules/ARCHITECTURE.md)
38
+ - [使用文档](/Users/bytedance/projects/vibe-forge.ai/.ai/rules/USAGE.md)
39
39
  - [CLI 维护说明](/Users/bytedance/projects/vibe-forge.ai/apps/cli/src/AGENTS.md)
@@ -1,11 +1,22 @@
1
- import { describe, expect, it } from 'vitest'
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2
2
 
3
- import { createMcpTools } from '#~/tools/index.js'
3
+ import askUser from '#~/tools/interaction/ask-user.js'
4
4
  import wait from '#~/tools/general/wait.js'
5
+ import { createMcpTools } from '#~/tools/index.js'
5
6
 
6
7
  import { createToolTester } from './mcp-test-utils.js'
7
8
 
8
9
  describe('mcp tools integration', () => {
10
+ beforeEach(() => {
11
+ process.env.__VF_PROJECT_AI_SESSION_ID__ = 'sess-1'
12
+ vi.stubGlobal('fetch', vi.fn())
13
+ })
14
+
15
+ afterEach(() => {
16
+ delete process.env.__VF_PROJECT_AI_SESSION_ID__
17
+ vi.unstubAllGlobals()
18
+ })
19
+
9
20
  it('registers task tools by default', () => {
10
21
  expect(createMcpTools()).toHaveProperty('task')
11
22
  })
@@ -46,4 +57,39 @@ describe('mcp tools integration', () => {
46
57
  .rejects.toThrow()
47
58
  })
48
59
  })
60
+
61
+ describe('AskUserQuestion tool', () => {
62
+ it('returns scalar answers as plain text content', async () => {
63
+ const tester = createToolTester()
64
+ askUser(tester.mockRegister)
65
+ vi.mocked(fetch).mockResolvedValue({
66
+ ok: true,
67
+ json: async () => ({ success: true, data: { result: '米饭' } })
68
+ } as Response)
69
+
70
+ const result = await tester.callTool('AskUserQuestion', {
71
+ question: '今晚吃了什么?',
72
+ options: [{ label: '米饭' }]
73
+ }) as any
74
+
75
+ expect(result.content).toEqual([{ type: 'text', text: '米饭' }])
76
+ })
77
+
78
+ it('returns multiselect answers as newline-separated text', async () => {
79
+ const tester = createToolTester()
80
+ askUser(tester.mockRegister)
81
+ vi.mocked(fetch).mockResolvedValue({
82
+ ok: true,
83
+ json: async () => ({ success: true, data: { result: ['米饭', '面条'] } })
84
+ } as Response)
85
+
86
+ const result = await tester.callTool('AskUserQuestion', {
87
+ question: '今晚吃了什么?',
88
+ options: [{ label: '米饭' }, { label: '面条' }],
89
+ multiselect: true
90
+ }) as any
91
+
92
+ expect(result.content).toEqual([{ type: 'text', text: '米饭\n面条' }])
93
+ })
94
+ })
49
95
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-forge/mcp",
3
- "version": "0.8.0",
3
+ "version": "0.8.4",
4
4
  "description": "Vibe Forge MCP server",
5
5
  "imports": {
6
6
  "#~/*.js": {
@@ -33,13 +33,13 @@
33
33
  "@modelcontextprotocol/sdk": "^1.25.3",
34
34
  "commander": "^12.1.0",
35
35
  "zod": "^3.24.1",
36
- "@vibe-forge/cli-helper": "^0.8.0",
37
- "@vibe-forge/config": "^0.8.0",
36
+ "@vibe-forge/hooks": "^0.8.4",
37
+ "@vibe-forge/task": "^0.8.4",
38
+ "@vibe-forge/config": "^0.8.4",
39
+ "@vibe-forge/types": "^0.8.4",
40
+ "@vibe-forge/utils": "^0.8.4",
38
41
  "@vibe-forge/register": "^0.8.0",
39
- "@vibe-forge/hooks": "^0.8.0",
40
- "@vibe-forge/task": "^0.8.0",
41
- "@vibe-forge/utils": "^0.8.0",
42
- "@vibe-forge/types": "^0.8.0"
42
+ "@vibe-forge/cli-helper": "^0.8.0"
43
43
  },
44
44
  "scripts": {
45
45
  "test": "pnpm -C ../.. exec vitest run --workspace vitest.workspace.ts --project bundler packages/mcp/__tests__"
package/src/command.ts CHANGED
@@ -4,9 +4,9 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
4
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
5
5
  import type { Command } from 'commander'
6
6
 
7
- import type { McpOptions } from './types'
8
7
  import { createMcpTools } from './tools'
9
8
  import { createFilteredRegister, shouldEnableCategory } from './tools/proxy'
9
+ import type { McpOptions } from './types'
10
10
 
11
11
  export const configureMcpCommand = (command: Command, version: string) => (
12
12
  command
@@ -1,7 +1,7 @@
1
1
  import wait from './general/wait'
2
2
  import askUser from './interaction/ask-user'
3
- import type { Register } from './types'
4
3
  import { createTaskRegister } from './task'
4
+ import type { Register } from './types'
5
5
 
6
6
  export const createMcpTools = (): Record<string, Register> => ({
7
7
  general: (server) => {
@@ -49,12 +49,35 @@ export default defineRegister(({ registerTool }) => {
49
49
  throw new Error(`Failed to ask user question: ${response.statusText} - ${errorText}`)
50
50
  }
51
51
 
52
- const result = await response.json()
52
+ const result = await response.json() as { data?: unknown; result?: unknown } | unknown
53
+ const body = (
54
+ result != null &&
55
+ typeof result === 'object' &&
56
+ 'data' in result
57
+ ? (result as { data?: unknown }).data
58
+ : result
59
+ )
60
+ const answer = (
61
+ body != null &&
62
+ typeof body === 'object' &&
63
+ 'result' in body
64
+ ? (body as { result?: unknown }).result
65
+ : body
66
+ )
67
+
68
+ if (answer == null) {
69
+ throw new Error('AskUserQuestion returned an empty result')
70
+ }
71
+
72
+ const text = Array.isArray(answer)
73
+ ? answer.map(item => String(item)).join('\n')
74
+ : String(answer)
75
+
53
76
  return {
54
77
  content: [
55
78
  {
56
79
  type: 'text',
57
- text: JSON.stringify(result.result)
80
+ text
58
81
  }
59
82
  ]
60
83
  }
@@ -117,6 +117,7 @@ export class TaskManager {
117
117
  skills: resolvedConfig.skills,
118
118
  mcpServers: resolvedConfig.mcpServers,
119
119
  promptAssetIds: resolvedConfig.promptAssetIds,
120
+ assetBundle: resolvedConfig.assetBundle,
120
121
  onEvent: (event: McpTaskOutputEvent) => {
121
122
  this.handleEvent(taskId, event)
122
123
  }