@akiojin/unity-mcp-server 2.14.15 → 2.14.16
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/package.json
CHANGED
|
@@ -56,7 +56,8 @@ export class ScriptSymbolFindToolHandler extends BaseToolHandler {
|
|
|
56
56
|
if (await this.index.isReady()) {
|
|
57
57
|
const rows = await this.index.querySymbols({ name, kind, scope, exact });
|
|
58
58
|
results = rows.map(r => ({
|
|
59
|
-
|
|
59
|
+
// Index returns project-relative paths already
|
|
60
|
+
path: (r.path || '').replace(/\\\\/g, '/'),
|
|
60
61
|
symbol: {
|
|
61
62
|
name: r.name,
|
|
62
63
|
kind: r.kind,
|
|
@@ -73,19 +74,28 @@ export class ScriptSymbolFindToolHandler extends BaseToolHandler {
|
|
|
73
74
|
if (!this.lsp) this.lsp = new LspRpcClient(info.projectRoot);
|
|
74
75
|
const resp = await this.lsp.request('workspace/symbol', { query: String(name) });
|
|
75
76
|
const arr = resp?.result || [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
const root = String(info.projectRoot || '').replace(/\\\\/g, '/');
|
|
78
|
+
const rootWithSlash = root.endsWith('/') ? root : (root + '/');
|
|
79
|
+
results = arr.map(s => {
|
|
80
|
+
const uri = String(s.location?.uri || '');
|
|
81
|
+
// Normalize to absolute path without scheme
|
|
82
|
+
const abs = uri.replace('file://', '').replace(/\\\\/g, '/');
|
|
83
|
+
// Convert to project-relative if under project root
|
|
84
|
+
const rel = abs.startsWith(rootWithSlash) ? abs.slice(rootWithSlash.length) : abs;
|
|
85
|
+
return {
|
|
86
|
+
path: rel,
|
|
87
|
+
symbol: {
|
|
88
|
+
name: s.name,
|
|
89
|
+
kind: this.mapKind(s.kind),
|
|
90
|
+
namespace: null,
|
|
91
|
+
container: null,
|
|
92
|
+
startLine: (s.location?.range?.start?.line ?? 0) + 1,
|
|
93
|
+
startColumn: (s.location?.range?.start?.character ?? 0) + 1,
|
|
94
|
+
endLine: (s.location?.range?.end?.line ?? 0) + 1,
|
|
95
|
+
endColumn: (s.location?.range?.end?.character ?? 0) + 1,
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
});
|
|
89
99
|
}
|
|
90
100
|
// Optional post-filtering: scope and exact name
|
|
91
101
|
if (scope && scope !== 'all') {
|
|
@@ -94,7 +104,9 @@ export class ScriptSymbolFindToolHandler extends BaseToolHandler {
|
|
|
94
104
|
switch (scope) {
|
|
95
105
|
case 'assets': return p.startsWith('Assets/');
|
|
96
106
|
case 'packages': return p.startsWith('Packages/') || p.startsWith('Library/PackageCache/');
|
|
97
|
-
case 'embedded': return p.startsWith('Packages/');
|
|
107
|
+
case 'embedded': return p.startsWith('Packages/');
|
|
108
|
+
default: return true;
|
|
109
|
+
}
|
|
98
110
|
});
|
|
99
111
|
}
|
|
100
112
|
if (exact) {
|
|
@@ -93,32 +93,38 @@ export class CSharpLspUtils {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
async downloadTo(url, dest) {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
const headers = { 'User-Agent': 'unity-mcp-server' };
|
|
97
|
+
const fetchOnce = async () => {
|
|
98
|
+
const r = await fetch(url, { headers });
|
|
99
|
+
if (!r.ok) throw new Error(`HTTP ${r.status} for ${url}`);
|
|
100
|
+
return r;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const res = await fetchOnce();
|
|
99
104
|
const body = res.body;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
file.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
} catch (e) {
|
|
119
|
-
const ab = await res.arrayBuffer();
|
|
120
|
-
await fs.promises.writeFile(dest, Buffer.from(ab));
|
|
105
|
+
|
|
106
|
+
// Prefer WebStream -> Node stream piping
|
|
107
|
+
if (body) {
|
|
108
|
+
try {
|
|
109
|
+
const file = fs.createWriteStream(dest);
|
|
110
|
+
const { Readable } = await import('node:stream');
|
|
111
|
+
const nodeStream = Readable.fromWeb(body);
|
|
112
|
+
await new Promise((resolve, reject) => {
|
|
113
|
+
nodeStream.pipe(file);
|
|
114
|
+
nodeStream.on('error', reject);
|
|
115
|
+
file.on('finish', resolve);
|
|
116
|
+
file.on('error', reject);
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
// If streaming failed or body was already consumed, re-fetch and fall back to arrayBuffer
|
|
121
|
+
}
|
|
121
122
|
}
|
|
123
|
+
|
|
124
|
+
// Fallback: re-fetch fresh response and write full buffer
|
|
125
|
+
const res2 = await fetchOnce();
|
|
126
|
+
const ab = await res2.arrayBuffer();
|
|
127
|
+
await fs.promises.writeFile(dest, Buffer.from(ab));
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
async sha256File(file) {
|