Release v0.2.0
This commit is contained in:
+40
-1
@@ -4,6 +4,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { getCurrentSelection, queryAssetInfo, queryAssetMeta } = require('./assets');
|
||||
const { runScriptDiagnostics } = require('./diagnostics');
|
||||
const { getRecentProjectLogs } = require('./logs');
|
||||
const { resolveProjectPath } = require('./path-safety');
|
||||
|
||||
function createResource(uri, name, description) {
|
||||
@@ -49,10 +50,11 @@ function summarizeSelection() {
|
||||
}
|
||||
|
||||
class ResourceProvider {
|
||||
constructor(getRuntimeContext, sceneBridge, interactionLog) {
|
||||
constructor(getRuntimeContext, sceneBridge, interactionLog, runtimeLog) {
|
||||
this.getRuntimeContext = getRuntimeContext;
|
||||
this.sceneBridge = sceneBridge;
|
||||
this.interactionLog = interactionLog;
|
||||
this.runtimeLog = runtimeLog;
|
||||
}
|
||||
|
||||
listResources() {
|
||||
@@ -65,6 +67,8 @@ class ResourceProvider {
|
||||
createResource('cocos://selection/current', `${projectName} Current Selection`, 'Summary of the current editor selection.'),
|
||||
createResource('cocos://selection/asset', `${projectName} Selected Asset`, 'Details for the currently selected asset.'),
|
||||
createResource('cocos://errors/scripts', `${projectName} Script Diagnostics`, 'Latest TypeScript diagnostic summary for the project.'),
|
||||
createResource('cocos://logs/editor', `${projectName} Editor Logs`, 'Recent MCP runtime logs and tool interaction history.'),
|
||||
createResource('cocos://logs/project', `${projectName} Project Logs`, 'Recent tails from common project log files.'),
|
||||
createResource('cocos://mcp/interactions', `${projectName} MCP Interactions`, 'Recent MCP tool interaction summaries.'),
|
||||
];
|
||||
}
|
||||
@@ -121,6 +125,10 @@ class ResourceProvider {
|
||||
return await this.getSelectedAssetText();
|
||||
case 'cocos://errors/scripts':
|
||||
return await this.getScriptDiagnosticsText(projectPath);
|
||||
case 'cocos://logs/editor':
|
||||
return this.getEditorLogsText();
|
||||
case 'cocos://logs/project':
|
||||
return this.getProjectLogsText(projectPath);
|
||||
case 'cocos://mcp/interactions':
|
||||
return this.interactionLog.summary();
|
||||
default:
|
||||
@@ -247,6 +255,37 @@ class ResourceProvider {
|
||||
return `Script diagnostics failed: ${error.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
getEditorLogsText() {
|
||||
return [
|
||||
'MCP Runtime Logs',
|
||||
this.runtimeLog && typeof this.runtimeLog.summary === 'function'
|
||||
? this.runtimeLog.summary(80)
|
||||
: 'Runtime log is unavailable.',
|
||||
'',
|
||||
'MCP Tool Interactions',
|
||||
this.interactionLog && typeof this.interactionLog.summary === 'function'
|
||||
? this.interactionLog.summary(80)
|
||||
: 'Interaction log is unavailable.',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
getProjectLogsText(projectPath) {
|
||||
const logs = getRecentProjectLogs(projectPath, { limit: 10, lines: 100 });
|
||||
if (!logs.length) {
|
||||
return 'No project log files found in common project log directories.';
|
||||
}
|
||||
|
||||
return logs
|
||||
.map((log) => [
|
||||
`# ${log.path}`,
|
||||
`mtime: ${log.mtime}`,
|
||||
`size: ${log.size}`,
|
||||
'',
|
||||
log.text,
|
||||
].join('\n'))
|
||||
.join('\n\n---\n\n');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user