gopeak 2.2.0 → 2.2.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.
@@ -0,0 +1,163 @@
1
+ import { ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
2
+ const PROMPTS_PAGE_SIZE = 20;
3
+ function getTrimmedArg(args, key) {
4
+ const value = args?.[key];
5
+ if (typeof value !== 'string') {
6
+ return undefined;
7
+ }
8
+ const trimmed = value.trim();
9
+ return trimmed.length > 0 ? trimmed : undefined;
10
+ }
11
+ function requireArg(args, key, promptName) {
12
+ const value = getTrimmedArg(args, key);
13
+ if (!value) {
14
+ throw new McpError(ErrorCode.InvalidParams, `Prompt '${promptName}' requires argument '${key}'`);
15
+ }
16
+ return value;
17
+ }
18
+ const promptTemplates = [
19
+ {
20
+ prompt: {
21
+ name: 'godot.scene_bootstrap',
22
+ title: 'Godot Scene Bootstrap',
23
+ description: 'Generate a deterministic scene bootstrap plan and starter GDScript wiring for a new gameplay scene.',
24
+ arguments: [
25
+ {
26
+ name: 'project_path',
27
+ description: 'Absolute path to the Godot project directory.',
28
+ required: true,
29
+ },
30
+ {
31
+ name: 'scene_path',
32
+ description: 'Scene path to create, for example: res://scenes/Player.tscn',
33
+ required: true,
34
+ },
35
+ {
36
+ name: 'root_node_type',
37
+ description: 'Root node type for the scene. Defaults to Node2D.',
38
+ },
39
+ {
40
+ name: 'feature_goal',
41
+ description: 'Short feature goal to guide node and script choices.',
42
+ },
43
+ ],
44
+ },
45
+ render: (args) => {
46
+ const projectPath = requireArg(args, 'project_path', 'godot.scene_bootstrap');
47
+ const scenePath = requireArg(args, 'scene_path', 'godot.scene_bootstrap');
48
+ const rootNodeType = getTrimmedArg(args, 'root_node_type') || 'Node2D';
49
+ const featureGoal = getTrimmedArg(args, 'feature_goal') || 'Create a playable prototype with clear input and movement behavior.';
50
+ return {
51
+ description: 'Deterministic checklist for creating and wiring a new Godot scene.',
52
+ messages: [
53
+ {
54
+ role: 'user',
55
+ content: {
56
+ type: 'text',
57
+ text: [
58
+ 'Bootstrap a Godot scene using this deterministic sequence:',
59
+ `- Project path: ${projectPath}`,
60
+ `- Scene path: ${scenePath}`,
61
+ `- Root node type: ${rootNodeType}`,
62
+ `- Goal: ${featureGoal}`,
63
+ '',
64
+ 'Execute in order:',
65
+ '1) Call project.info to confirm project metadata and main scene.',
66
+ `2) Call scene.create with scene_path='${scenePath}' and root_node_type='${rootNodeType}'.`,
67
+ '3) Add core nodes with scene.node.add (or add_node), then save the scene.',
68
+ '4) Create or modify the attached script with script.create/script.modify using typed exports for tunable values.',
69
+ '5) Run editor.run on the same project path, collect editor.debug_output, and fix top blocking errors.',
70
+ '6) Return a concise summary containing created nodes, script path, and unresolved risks.',
71
+ ].join('\n'),
72
+ },
73
+ },
74
+ ],
75
+ };
76
+ },
77
+ },
78
+ {
79
+ prompt: {
80
+ name: 'godot.debug_triage',
81
+ title: 'Godot Debug Triage',
82
+ description: 'Run a focused Godot debug triage loop from reproduction to verified fix.',
83
+ arguments: [
84
+ {
85
+ name: 'project_path',
86
+ description: 'Absolute path to the Godot project directory.',
87
+ required: true,
88
+ },
89
+ {
90
+ name: 'error_excerpt',
91
+ description: 'Error excerpt from Godot output or debugger panel.',
92
+ required: true,
93
+ },
94
+ {
95
+ name: 'repro_steps',
96
+ description: 'Optional reproduction steps observed by the developer.',
97
+ },
98
+ ],
99
+ },
100
+ render: (args) => {
101
+ const projectPath = requireArg(args, 'project_path', 'godot.debug_triage');
102
+ const errorExcerpt = requireArg(args, 'error_excerpt', 'godot.debug_triage');
103
+ const reproSteps = getTrimmedArg(args, 'repro_steps') || 'No reproduction steps provided.';
104
+ return {
105
+ description: 'Deterministic debug triage workflow for Godot runtime/editor errors.',
106
+ messages: [
107
+ {
108
+ role: 'user',
109
+ content: {
110
+ type: 'text',
111
+ text: [
112
+ 'Triage and fix this Godot issue with deterministic steps:',
113
+ `- Project path: ${projectPath}`,
114
+ `- Error excerpt: ${errorExcerpt}`,
115
+ `- Repro steps: ${reproSteps}`,
116
+ '',
117
+ 'Workflow:',
118
+ '1) Call editor.run for the target project and reproduce once.',
119
+ '2) Collect logs with editor.debug_output and parse_error_log; isolate the first root-cause error.',
120
+ '3) Use lsp.diagnostics/lsp_get_hover on the implicated script(s) before editing.',
121
+ '4) Apply the smallest fix with script.modify or scene/resource tools.',
122
+ '5) Re-run editor.run and confirm the original error excerpt no longer appears.',
123
+ '6) Report root cause, changed files, and any follow-up checks.',
124
+ ].join('\n'),
125
+ },
126
+ },
127
+ ],
128
+ };
129
+ },
130
+ },
131
+ ];
132
+ const promptTemplatesByName = new Map(promptTemplates.map((template) => [template.prompt.name, template]));
133
+ function parsePromptsListCursor(cursor, total) {
134
+ if (typeof cursor !== 'string' || cursor.length === 0) {
135
+ return 0;
136
+ }
137
+ const offset = Number.parseInt(cursor, 10);
138
+ if (!Number.isInteger(offset) || offset < 0 || offset > total) {
139
+ throw new McpError(ErrorCode.InvalidParams, `Invalid prompts/list cursor: ${cursor}`);
140
+ }
141
+ return offset;
142
+ }
143
+ export function listPrompts(cursor) {
144
+ const promptDefs = promptTemplates.map((template) => template.prompt);
145
+ const start = parsePromptsListCursor(cursor, promptDefs.length);
146
+ const end = Math.min(start + PROMPTS_PAGE_SIZE, promptDefs.length);
147
+ const page = promptDefs.slice(start, end);
148
+ if (end < promptDefs.length) {
149
+ return {
150
+ prompts: page,
151
+ nextCursor: String(end),
152
+ };
153
+ }
154
+ return { prompts: page };
155
+ }
156
+ export function getPrompt(name, args) {
157
+ const template = promptTemplatesByName.get(name);
158
+ if (!template) {
159
+ const available = promptTemplates.map((entry) => entry.prompt.name).join(', ');
160
+ throw new McpError(ErrorCode.InvalidParams, `Unknown prompt: ${name}. Available prompts: ${available}`);
161
+ }
162
+ return template.render(args);
163
+ }
@@ -87,7 +87,7 @@ export async function serveVisualization(projectData, bridge) {
87
87
  bridge.on('tool_end', onToolEnd);
88
88
  bridge.on('godot_connected', onGodotConnected);
89
89
  bridge.on('godot_disconnected', onGodotDisconnected);
90
- const url = 'http://localhost:6505';
90
+ const url = `http://localhost:${bridge.getStatus().port}`;
91
91
  console.error(`[visualizer] Serving at ${url}`);
92
92
  openBrowser(url);
93
93
  return url;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "gopeak",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "mcpName": "io.github.HaD0Yun/gopeak",
5
5
  "description": "GoPeak — The most comprehensive MCP server for Godot Engine. 95+ tools: scene management, GDScript LSP diagnostics, DAP debugger, screenshot capture, input injection, ClassDB introspection, CC0 asset library. AI-assisted game development with Claude, Cursor, Cline, OpenCode.",
6
6
  "type": "module",
7
7
  "main": "./build/index.js",
8
8
  "bin": {
9
- "gopeak": "./build/index.js",
10
- "godot-mcp": "./build/index.js"
9
+ "gopeak": "./build/cli.js",
10
+ "godot-mcp": "./build/cli.js"
11
11
  },
12
12
  "files": [
13
13
  "build",
@@ -16,10 +16,16 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "build": "tsc && node scripts/build-visualizer.js && node scripts/build.js",
19
+ "typecheck": "tsc --noEmit",
20
+ "test:smoke": "node scripts/smoke-test.mjs",
21
+ "test:integration": "node test-bridge.mjs",
22
+ "test:ci": "npm run test:smoke",
23
+ "ci": "npm run build && npm run typecheck && npm run test:ci",
19
24
  "prepare": "npm run build",
20
25
  "watch": "tsc --watch",
21
26
  "inspector": "npx @modelcontextprotocol/inspector build/index.js",
22
- "pack": "npm pack --dry-run"
27
+ "pack": "npm pack --dry-run",
28
+ "version:bump": "node scripts/bump-version.mjs"
23
29
  },
24
30
  "engines": {
25
31
  "node": ">=18"